Results 1 to 5 of 5
Hi,
im trying to write a script to check the port 22 of 4 IPs.
IPS={89.17.206.180,89.17.206.185,89.17.206.186,89. 17.206.187}
for i in ${IPS}
do
nmap -p 22 {IPS}
done
but i get ...
- 07-07-2009 #1Just Joined!
- Join Date
- Apr 2007
- Posts
- 22
Problema con "for" in a bash script
Hi,
im trying to write a script to check the port 22 of 4 IPs.
IPS={89.17.206.180,89.17.206.185,89.17.206.186,89. 17.206.187}
for i in ${IPS}
do
nmap -p 22 {IPS}
done
but i get this error:
Failed to resolve given hostname/IP: {IPS}. Note that you can't use '/mask' AND '1-4,7,100-' style IP ranges
WARNING: No targets were specified, so 0 hosts scanned.
Nmap done: 0 IP addresses (0 hosts up) scanned in 0.14 seconds
Any idea?
- 07-07-2009 #2
You are using the call to the variable containing each IP address incorrectly within the for loop. The line:
Will take each item in $IPS and give it the variable name of iCode:for i in ${IPS}
Code:IPS={89.17.206.180,89.17.206.185,89.17.206.186,89. 17.206.187} for i in ${IPS} do nmap -p 22 ${i} doneLinux User #453176
- 07-07-2009 #3Just Joined!
- Join Date
- Apr 2007
- Posts
- 22
Thanks both!, anyway i have extended my code and now im trying to print "Closed" or "Open" depending on the state of the port.
My problem: it just prints "Open" one time, i mean: in this code below i have two IPs, but it seams the code is not considering none of them.
Any idea?Code:#IPS="89.17.206.129,89.17.206.132" for i in ${IPS} do if [ -z 'nmap -p 22 $i |grep open' ]; then echo "Closed" else echo "Open" fi done
- 07-07-2009 #4
You have commented out your first line
Linux User #453176
- 07-08-2009 #5Just Joined!
- Join Date
- Apr 2007
- Posts
- 22
Hi again,
i have the answer:
Code:IPS="$(seq -f "89.17.206.%.0f" 129 189) $(seq -f "89.17.219.%.0f" 65 126)"


Reply With Quote