kathys39
asked on
parsing a line in nmap's output
I am using nmap::parser to parse the results of an nmap scan. One thing this module does not provide for is obtaining information about hosts that don't respond to a ping. Nmap reports these hosts as "up", and in the output file the ports scanned are listed as "extraports". I can get the number of these ports, but not the actual ports themselves. In order to to do, I am parsing the args variable, which is what I need help with. This is the content of a sample args variable:
args = "nmap -sS -P0 -vv -p21,23,25,80 -O ...."
The critical part is here is that I want to search/grep for "-p" in the variable $args, then read everything past the "-p" to the next space. So in the example above my new variable would contain "21,23,25,80". I'll then split that via the comma. What I can't figure out is how to search/grep for "-p" in a variable, and read thru until I hit a space. Can anyone help me with that in perl? Thank you.
args = "nmap -sS -P0 -vv -p21,23,25,80 -O ...."
The critical part is here is that I want to search/grep for "-p" in the variable $args, then read everything past the "-p" to the next space. So in the example above my new variable would contain "21,23,25,80". I'll then split that via the comma. What I can't figure out is how to search/grep for "-p" in a variable, and read thru until I hit a space. Can anyone help me with that in perl? Thank you.
($read) = $args =~ /-p(\S*)/;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
excellent, thank you!