Results 1 to 2 of 2
Code:
[root@pxe tmp]# vi test1
#!/bin/bash
a="nmap -p80 xx.xx.xx.xx | awk '{print $2}'|grep open"
b="open"
echo
if [ "$a" != "$b" ]
then
echo "doesn't match"
elif
["$a" == "$b" ...
- 07-11-2011 #1Just Joined!
- Join Date
- Jul 2009
- Posts
- 24
BASH and NMAP
It always comes back as "doesn't match". I also get this error when I have the variable set in the environment:Code:[root@pxe tmp]# vi test1 #!/bin/bash a="nmap -p80 xx.xx.xx.xx | awk '{print $2}'|grep open" b="open" echo if [ "$a" != "$b" ] then echo "doesn't match" elif ["$a" == "$b" ] then echo "Matches!" fi
I'm thinking this error would be the issue. What am I doing wrong?Code:[root@pxe tmp]# a="nmap -p80 xx.xx.xx.xx| awk '{print $2}'|grep open" [root@pxe tmp]# $a Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2011-07-11 10:11 MST Invalid target host specification: | QUITTING!
Please note, the xx.xx.xx.xx is actually an IP address in my script
- 07-11-2011 #2Just Joined!
- Join Date
- Jul 2009
- Posts
- 24
Fixed, here's the revised script:
Code:#!/bin/bash a=$(nmap -p80 xx.xx.xx.xx | awk '{print $2}'|grep open) b="open" eval "$a" echo if [ "$a" != "$b" ] then service httpd start fi


Reply With Quote