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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IFTHENELSE HELP

Status
Not open for further replies.

galger

MIS
Jan 16, 2002
79
US
Is there another way I can State this? It does not work the way it is. Any help would be appreciated.

#!/bin/sh
#
echo "Please enter the word SLHNDMP SLHNDMP_VB PRGTEST_GDG or PRGTEST:"
read PASSWORD

if [ PASSWORD = SLHNDMP ]; then
echo "Ran for SLHNDMP "


if [ PASSWORD = SLHNDMP_VB ]; then
echo "Ran for SLHNDMP_VB "


if [ PASSWORD = PRGTEST_GDG ]; then
echo "Ran for PRGTEST_GDG "

if [ PASSWORD = PRGTEST ]; then
echo "Ran for PRGTEST"

else
echo "None selected"
exit 0
fi
fi
fi
fi


Given two equally predictive theories, choose the simpler.
 
This isn't doing what you think it is. Look up the "[tt]case[/tt]" statement. That's what you want.

 
I see what you mean .. thanks for the hint.

#!/bin/sh
#
echo "Please enter the word SLHNDMP SLHNDMP_VB PRGTEST_GDG or PRGTEST:"
read PASSWORD

case "$PASSWORD" in
"SLHNDMP" )
echo "Ran for SLHNDMP "
;;
"SLHNDMP_VB" )
echo "Ran for SLHNDMP_VB "
;;
"PRGTEST_GDG" )
echo "Ran for PRGTEST_GDG "
;;
"PRGTEST" )
echo "Ran for PRGTEST"
;;
* )
echo "None selected"
;;
esac

Given two equally predictive theories, choose the simpler.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top