bin sh while getopts sPn option do case option in if echo OPTARG cut -

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#!/bin/sh
while getopts sPn: option
do
case $option in
n)
if [ `echo "$OPTARG" | cut -d '.' -f 3` = 1 ]
then ssh user_nmap@192.168.1.1 $OPTARG; #Office 192.168.1.1
elif [ `echo "$OPTARG" | cut -d '.' -f 3` = 2 ]
then ssh user_nmap@192.168.2.1 $OPTARG; #Office 192.168.2.1
elif [ `echo "$OPTARG" | cut -d '.' -f 3` = 3 ] && [ `echo "$OPTARG" | cut -d '.' -f 4 | cut -d '/' -f 1` = 129 ]
then ssh user_nmap@192.168.3.1 $OPTARG; #Office 192.168.3.129
fi
esac
done