toolic's already answered the -> question, so I'll focus on the port scan here.

You can use Nmap::Scanner for this task. I must tell you that while fudging the below example, I found errors in the docs throughout the distribution (I've made myself a reminder and I'll go through it more thoroughly later and patch them). This example is nearly copy and paste from the various SYNOPSIS from the modules.

The most notable err in the docs is the call to get_host_list(). In the docs, they specify gethostlist(), which doesn't exist.

Also, you *must* install nmap before installing Nmap::Scanner, and if you get any weird errors upon running your script, you may need to install XML::SAX::Expat as well (I found that solution in this post, in this thread here on PM).

use strict; use warnings; use Nmap::Scanner; my @systems = qw(localhost other); my $scanner = new Nmap::Scanner; $scanner->tcp_syn_scan; $scanner->add_scan_port('22'); $scanner->add_scan_port('80-82'); for (@systems){ $scanner->add_target($_); } my $results = $scanner->scan; my $hosts = $results->get_host_list; while (my $host = $hosts->get_next) { print "\nOn " . $host->hostname . ": \n"; my $ports = $host->get_port_list; while (my $port = $ports->get_next) { print join(' ', 'Port', $port->portid, 'is in state', $port->state, "\n" ); } } __END__ On localhost: Port 22 is in state open Port 80 is in state closed Port 81 is in state closed Port 82 is in state closed On other: Port 22 is in state closed Port 80 is in state closed Port 81 is in state closed Port 82 is in state closed

In reply to Re: port check by stevieb
in thread port check by deelinux

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.