Hi,

I have the following perl code:
use Nmap::Scanner; my $scan = Nmap::Scanner->new(); $scan->add_target('localhost'); $scan->add_scan_port('16310-16316'); $scan->tcp_syn_scan(); my $results = $scan->scan();

But it is throwing error:
[root@station19 ~]# perl nmap.pl <nmap-error> <pid="8711"/> <cmdline="'/usr/bin/nmap' -v -v -v -sS -p 16310-16316 -oX - localhos +t"/> <nmap-err>mass_dns: warning: Unable to determine any DNS servers. Re +verse DNS is disabled. Try using --system-dns or specify valid server +s with --dns_servers </nmap-msg> </nmap-error>

and the output when I run the nmap command from command line is:
[root@station19 ~]# '/usr/bin/nmap' -v -v -v -sS -p 16310-16316 -oX - +localhost <?xml version="1.0" ?> <?xml-stylesheet href="/usr/share/nmap/nmap.xsl" type="text/xsl"?> <!-- Nmap 4.11 scan initiated Tue Jan 3 16:17:13 2012 as: /usr/bin/nm +ap -v -v -v -sS -p 16310-16316 -oX - localhost --> <nmaprun scanner="nmap" args="/usr/bin/nmap -v -v -v -sS -p 16310-1631 +6 -oX - localhost" start="1325587633" startstr="Tue Jan 3 16:17:13 2 +012" version="4.11" xmloutputversion="1.01"> <scaninfo type="syn" protocol="tcp" numservices="7" services="16310-16 +316" /> <verbose level="3" /> <debugging level="0" /> mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is + disabled. Try using --system-dns or specify valid servers with --dns +_servers <host><status state="up" /> <address addr="127.0.0.1" addrtype="ipv4" /> <hostnames><hostname name="localhost.localdomain" type="PTR" /></hostn +ames> <ports><port protocol="tcp" portid="16310"><state state="open" /></por +t> <port protocol="tcp" portid="16311"><state state="open" /></port> <port protocol="tcp" portid="16312"><state state="open" /></port> <port protocol="tcp" portid="16313"><state state="open" /></port> <port protocol="tcp" portid="16314"><state state="open" /></port> <port protocol="tcp" portid="16315"><state state="open" /></port> <port protocol="tcp" portid="16316"><state state="open" /></port> </ports> </host> <runstats><finished time="1325587633" timestr="Tue Jan 3 16:17:13 201 +2"/><hosts up="1" down="0" total="1" /> <!-- Nmap run completed at Tue Jan 3 16:17:13 2012; 1 IP address (1 h +ost up) scanned in 0.010 seconds --> </runstats></nmaprun>

So, running from command line is giving some warning but still continuing and giving me the output which I want. But not the perl code. Is there anyway that I can get this perl code to be working?

Thanks,
Ashok

In reply to Problem with Nmap::Scanner by ashok.g

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.