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!

select statement - can multiple options be chosen?

Status
Not open for further replies.

westwood01

Technical User
Dec 28, 2003
41
US
Below is a portion of a (ksh) case script. The way the menu works now is, via the select statement I can only choose one of the numbered options at a time. Is there a way to choose multiple options?

For example, if I run the script and choose option 3, I will be presented with a list that looks like:

Listing of MARGE Failed Save Sets:

1) Jun 20 14:51:49 marge: atexentsys1:/
2) Jun 20 14:51:49 marge: atexentsys1:/oracle
3) Jun 20 14:51:49 marge: atexentsys1:/ora01
4) Jun 20 14:51:49 marge: atexentsys1:/orasrv
5) Jun 20 14:51:49 marge: atexentsys1:/apps
#?

At this (#?) point I can enter any one of the listed lines. Is there a way I can choose more than one?

Option 3 portion of the case script:

3) clear
grep marge data2.email > data3.marge
echo ""
echo "Listing of MARGE Failed Save Sets:"
echo ""
IFS="
"
select line in $(<data3.marge);do
echo ""
echo "You Selected $REPLY for $line"
echo "Create Ticket y/n?"
read reply1
if [ "$reply1" = "y" ]
then
echo "Processing . . . "
echo "$TODAY $TIME : $line" >> submitted.log
./maketicket;./system.ksh
else
echo "Request Cancelled"
./system.ksh
fi
done
nogo
badreply;;
 
In your ksh man page have a look at the while ... do ... done instruction.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
My case is within a while-do-done. If this is what you were getting at, can you please explain further how this would work? thanks.

while true
do
read input
case $input in
1) option1
2) option2
3) clear
grep marge data2.email > data3.marge
echo ""
echo "Listing of MARGE Failed Save Sets:"
echo ""
IFS="
"
select line in $(<data3.marge);do
echo ""
echo "You Selected $REPLY for $line"
echo "Create Ticket y/n?"
read reply1
if [ "$reply1" = "y" ]
then
echo "Processing . . . "
echo "$TODAY $TIME : $line" >> submitted.log
./maketicket;./system.ksh
else
echo "Request Cancelled"
./system.ksh
fi
done
nogo
badreply;;
*) echo "Please Try Again";sleep 1;./system.ksh
esac
done
 
You may play with nested loops ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
An example

while IFS=: read user pass uid gid fullname homedir shell < /etc/passwd
do
..... Process line
done

this would read each part of each line of /etc/passwd.



Mike

"A foolproof method for sculpting an elephant: first, get a huge block of marble, then you chip away everything that doesn't look like an elephant."

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top