Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need to ask for a second arguement for NFS. I have the vswitches labeled NFS. I am already asking for the IP but now I need to ask for the switch an example is NFS01, NFS02. I need a little help with the logic. I am very new to bash so please talk slow and try not to be cryptic.

#!/bin/ash -v



E_NOARGS=65

if [[ -z "$1" ]]
then
echo "Usage: ./`basename $0` [IP_Address]"
exit $E_NOARGS
fi

esxcfg-vswitch -m 9000 vSwitch2
esxcfg-vswitch -l
esxcfg-nics -l
sleep 15
esxcfg-vswitch -A NFS vSwitch2
sleep 10
esxcfg-vswitch -p NFS -v 20 vSwitch2
sleep 10
esxcfg-vmknic -a -i "$1" -n 255.255.255.0 -m 9000 NFS
sleep 10
vmkping -s 9000 192.168.9.3
share|improve this question

1 Answer 1

up vote 2 down vote accepted

Not sure if I really understand what you're asking, but something like the following might work for you...

if [ $# != 2 ]; then
  echo "Usage: ./`basename $0` [IP_Address] [switch]"
  exit $E_NOARGS
fi

Then use $2 wherever you need to specify the switch value.

share|improve this answer
    
Can you look below and tell me if this is what your talking about –  Randy May 4 '11 at 13:49
    
Is this what your say to do? I just want to verify before I run it on a production system. #!/bin/ash -v E_NOARGS=65 if [ $# != 2 ]; then echo "Usage: ./basename $0 [IP_Address] [switch]" exit $E_NOARGS fi esxcfg-vswitch -m 9000 vSwitch2 esxcfg-vswitch -l esxcfg-nics -l sleep 15 esxcfg-vswitch -A "$2" vSwitch2 sleep 10 esxcfg-vswitch -p "$2" -v 20 vSwitch2 sleep 10 esxcfg-vmknic -a -i "$1" -n 255.255.255.0 -m 9000 "$2" sleep 10 vmkping -s 9000 192.168.9.3 –  Randy May 4 '11 at 13:52
    
@randy I would never suggest deploying a change to a production system without testing it offline first, but it appears that you have correctly interpreted my suggestion. –  rlduffy May 5 '11 at 5:33
    
thanks for your help. –  Randy May 5 '11 at 20:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.