문제

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

도움이 되었습니까?

해결책

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

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top