Good evening all .
I am' trying to use the NOHANG function in my script for to maintain on 
live a process until the child process end its job.
but something go wrong .
when I run the script all work fine until i must to esc form the "cicle" 
ops! here the program sometime esc and sometime no!!
that's i think because not everytime the program start with the same 
process, so when the job is finish this seems to be append and don't esc.

First of all Sorry for my ugly english, and I think that somebody can 
help me.

Regards
Saffioti Goffredo.


This is a scanport for unixlike systems it seems to work :-) but on the 
while something go wrong follow the "****" for find the while.

#scanport3.pl write by GOFFREDO SAFFIOTI.
#!/usr/bin/perl -w
use IO::Socket;
use IPC::Open2;
use Term::ANSIColor;
use POSIX ":sys_wait_h";

my ($port, $sock, @servers);

my $pid = 0;
my($server, $begin, $end) = @ARGV;

&usage if (!$server);
$begin = 0 if (!$begin);
$end = 65000 if (!$end);

print "Scanning from $begin to $end\n";

my $status;
$pid = fork;
if ($pid != 0) {
    for ($port=$begin;$port<(($begin + $end)/2);$port++) {
    &scan;;
    if ( $sock ) {
         print color 'bold blue';   
             print "Connected on port $port\n";
    } else {
        print color 'bold blue';
            print "$port not connected\n";
    }
    }
    my $childpid;
    $status = 1;

****************************************************************************************
    while ($status = waitpid(-1, WNOHANG)) {      
     sleep(1);                                                        
         
    }                                                                    
         

"it's ok the use on this way for WNOANG in addition with a call to use 
POSIX":sys_wait_h";?? "
*******************************************************************************************
}
else
{

#    for ($port=(($begin + $end)/2);$port<=$end;$port++){
     for ($port=($end/2)+1;$port<=$end;$port++){
    &scan;
    if ( $sock ) {
        print color 'bold white';
            print "Connected on port $port\n";
    } else {
        print color 'bold white';
            print "$port not connected\n";
    }
    }
}


sub usage{
    print "Usage: portscan hostname [start at port number]\n";
exit(0);
}

sub scan{
    $sock = IO::Socket::INET->new(PeerAddr => $server,
                                  PeerPort => $port,
                                  Proto => 'tcp');
}

Help please.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to