Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looping in script 1

Status
Not open for further replies.

chomps303

MIS
Sep 30, 2003
83
US
I need a script to

1. ask a simple question
2. get answer
3. save answer in a flat file
4. loop and ask question again
5. if answer is null exit

***********************************************************
while true
doif [ $TTY = "" ]
then
break
else
echo "Enter ttyp to kill \c"
read TTY
cat $TTY >> ttylist
fi
done
***********************************************************

What am I doing wrong??

Thanks

Brandt


 
Try something like this:
Code:
while echo "Enter ttyp to kill \c"
do  read TTY
    if [ "$TTY" = "" ]
    then
        break
    else
        echo $TTY >> ttylist
    fi
done

Hope This Help
PH.
 
Another solution :

[tt]
while :
do
read TTY?"Enter ttyp to kill : "
[ -z "$TTY" ] && break
echo $TTY >> ttylist
done
[/tt]

Jean Pierre.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top