![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| stop execution of script with in the script | dsdev_123 | AIX | 3 | 03-20-2008 11:57 AM |
| Script to run non-stop | Raynon | Shell Programming and Scripting | 37 | 01-21-2008 05:36 AM |
| Script that doesn't stop | biot | UNIX for Dummies Questions & Answers | 3 | 11-30-2007 01:19 AM |
| stop Prstat using shell script | filthymonk | Shell Programming and Scripting | 19 | 05-23-2007 06:24 AM |
| Start/Stop Script | jjv1 | UNIX for Dummies Questions & Answers | 2 | 12-16-2003 04:28 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Script does not stop when doing a read
Hi Folks, I have been trying to create a script wherein after it reads a certain number of data, it will pause and ask the user if he wants to continue or not. However, it seems that when it is supposed to read the user's answer, the script will go into a loop. What is wrong with my script here? Code:
#!/usr/bin/ksh
trap exit 1 2 3 15
DataCtr=1
MaxData=10
while read CurrData
do
echo "Data# $CurrData"
if [[ $DataCtr -eq $MaxData ]] ; then
echo " "
echo "Data are almost done."
while :
do
echo "Continue to process? [y/n]: \c"
read YESNO
case "$YESNO" in
[yY]|[yY][eE][sS])
YESNO=y ; break ;;
[nN]|[nN][oO])
exit ;;
*)
YESNO="" ;;
esac
done
fi
echo "Processing data $CurrData"
DataCtr=`expr $DataCtr + 1`
done < testdata
echo "Finished!"
My testdata file will just contain text data. Thanks in advance for your help! Last edited by rooseter; 11-05-2007 at 03:40 AM.. Reason: changed continue to break |
|
||||
|
Hi porter,
"while :" would mean to do a loop of the whole while - do block. On this case, it is supposed to echo the question until the user either answers a Y (which on this case will execute the break command) and a N (which will exit the script). If you put the inner while-do block outside of the outer while-do, the routine will work. It is only when it is inside the outer while-do that the routine goes into loop. |
|
||||
|
porter, I have just tried using the TTY option, and it worked! I am just wondering why my current script will not work when on another script, it did (although it is placed outside of another while-do loop).
Anyway, thanks for your help on this! |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|