use while after if


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting use while after if
# 1  
Old 03-23-2009
use while after if

how to use while after if???

Code:
file=/tmp/test

if cmp /tmp/1 /tmp/2 &> /dev/null 
then echo "fail check ok"

while [ ! -s $file ]; do
     echo "$file is empty"
     wget http://link -O /tmp/test
     sleep 3
done
cat /tmp/test 

else echo "fail check fail"
do some action
fi

# 2  
Old 03-23-2009
bash:
Code:
file=/tmp/test

ok=0
cmp /tmp/1 /tmp/2 &> /dev/null  && ok=1
if [[ $ok -eq 1 ]] 
then 
   echo "fail check ok"

   while [ ! -s $file ]; do
     echo "$file is empty"
     wget http://link -O /tmp/test
     sleep 3
   done
   cat /tmp/test 

else 
   echo "fail check fail"
    # do some action
fi

# 3  
Old 03-23-2009
thnx !!!
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question