Bash script in VMware Check for 2 different inputs
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 -vE_NOARGS=65if [[ -z "$1" ]]
then
echo "Usage: ./`basename $0` [IP_Address]"
exit $E_NOARGS
fiesxcfg-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
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.
Check more discussion of this question.
Related posts:
Leave a comment
Recent Posts
Tags
active-directory
amazon-ec2
apache
apache2
backup
bash
centos
cisco
command-line
debian
dns
email
exchange
firewall
iis
iis7
iptables
linux
macosx
monitoring
mysql
networking
nginx
performance
permissions
php
postfix
raid
security
sql-server
sql-server-2005
sql-server-2008
ssh
ssl
ubuntu
unix
virtualization
vpn
webserver
windows
windows-7
windows-server-2003
windows-server-2008
windows-server-2008-r2
windows-xp





