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!

case script cannot exit

Status
Not open for further replies.

westwood01

Technical User
Dec 28, 2003
41
US
Below is an example of a case script I'm using. The script works as expected, except for the q (quit/exit) option; it won't exit. Actually the script does exit properly if I choose q before choosing any other option. Unlike if I choose 2, then try and q, it wont work. I believe it has something to do with the select statement I'm using, but I'm not entirely sure. Any ideas? Thanks.

#!/bin/ksh

TODAY=`date +%m/%d/%y`
TIME=`date +%H:%M:%S`

while true
do

echo "
1) View ALL Failed Save Sets
2) Create Tickets for SERVER1 Failed Save Sets
q) Quit"
echo ""

read input
case $input in
1) clear
echo ""
echo "Listing of All Failed Save Sets:"
echo ""
awk '{print $0}' data.dat;./script.ksh;;
2) clear
grep server1 data.dat > tmp.server1
echo "Select Failed Save Set to Create Remedy Ticket"
echo "Listing of Failed Save Sets:"
echo ""
IFS="
"
select line in $(<tmp2.server1);do
echo ""
echo "You Selected $REPLY for:
$line"
echo "Continue y/n?"
read reply1
if [ "$reply1" = "y" ]
then
echo "Working . . ."
echo "$TODAY $TIME : $line" >> submitted.log
./maketicket;./script.ksh
else
echo "Request Cancelled";sleep 1
./script.ksh
fi
done;;
q) echo "Exiting . . . ";sleep 1;exit;;
*) echo "Please Make Another Selection";sleep 1;clear;./script.ksh;;
esac
done
 
Thanks I'll try that.

You mentioned the indentation. Is using it needed when scripting or is strictly for being easier to read?
 
Just noticed your question. not a typo, just how I am passing around some of the data...
 
indentation is not necessary at all, but it makes reading scripts easier, especially with nested loops.

I understand the part of passing around some of the data, it just seems funny to me that you create ONE file by grepping for some string "server1" in your datafile, and then use ANOTHER file in the select loop...

Also there's another way to get out of the select loop: add a "Quit" to the temp file
echo "Quit3 >> tmp2.server1 just before you start the select loop

...
echo "Quit" >>tmp2.server1
select line in $(<tmp2.server1)
do
if [ "$line" = "Quit" ]
then
break
else
echo ""
echo "You Selected $REPLY for:
$line"
echo "Continue y/n?"
read reply1
if [ "$reply1" = "y" ]
then
echo "Working . . ."
./maketicket2
else
echo "Request Cancelled"
sleep 1
fi
done;;
...



HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top