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

Était-ce utile?

La 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);

Autres conseils

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top