The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 01-05-2009
rookieuxixsa rookieuxixsa is offline
Registered User
  
 

Join Date: Dec 2008
Location: NYC
Posts: 8
getopts question

I am trying to set up prompts when you don't enter the right information or dont enter the information at all, when executing a script. Below is the question that i am asking and i am not sure how to set up the if statements to make sure that the user enters the name, cpu's, memory and ip. I was told that getopts with a cease statement might be usefull, but im not sure how to apply it. Any help would be greatly appreciated...

NAME=$1
NCPUS=$2
MEMORY=$3
IP=$4
MACHINENAME=`hostname`
MASTERHOST=svvnyc702

echo "Do you wish to proceed with the creation of UAT ZONE zone-${NAME}, CPU's ${NCPUS}, MEMORY ${MEMORY}, IP ${IP}
<y or n> ? \c"

read WISH
echo
if [ $WISH = "n" ] ; then
echo "You chose no, good bye"
exit
fi
if [ ! $WISH = "y" ] ; then
echo in vaild optin g - exiting
exit
fi