Try replacing quotes by double-quotes:
$scanner->scan("-sS -p 1-1024 -sV -O --max-rtt-timeout 200ms $host");
or place $host
outside:
$scanner->scan('-sS -p 1-1024 -sV -O --max-rtt-timeout 200ms '.$host);
Question
Im running a perl script to scan several hosts. When i put a single host in
$scanner->scan('-sS -p 1-1024 -sV -O --max-rtt-timeout 200ms 111.111.111.111');
it runs fine, but when I try to add a variable value inside by parsing a file with list of hosts
$scanner->scan('-sS -p 1-1024 -sV -O --max-rtt-timeout 200ms $host');
The program just assumes $host as characters, is there anyway to get around this? I'm using nmap::scanner as my module.
Thanks
Solution
Try replacing quotes by double-quotes:
$scanner->scan("-sS -p 1-1024 -sV -O --max-rtt-timeout 200ms $host");
or place $host
outside:
$scanner->scan('-sS -p 1-1024 -sV -O --max-rtt-timeout 200ms '.$host);
OTHER TIPS
you are using the wrong type of quotes
'
does not interpolate variables so
$x='fish';
$b='deep fried $x';
sets $b to deep fried $x
whereas
$b="deep fried $x";
sets $b to deep fried fish
See perldoc perlop for more details