Can someone explain why the following simple script hangs after a certain
number of loops? It hangs on the 11th loop on my systems running OS X 10.2.2
and 10.2.3. Subsititue a remote host to which your system has rsh access for
_NAME_OF_REMOTE_HOST_ in command array below.

Thanks,
Aaron London

#!/usr/bin/perl

use FileHandle;

sub main
{
        my @cmd = ("/usr/bin/rsh",_NAME_OF_REMOTE_HOST_,"sleep","2");
        
        my $i = 1;
        my $h = {};
        while (1) {
                my $log = "$i.log";
                my $handle = new FileHandle ">>$log";
                $handle or die "Error: couldn't open '$i.log' for append:
$!\n";
                print "$i:open<$handle>\n";
                $h->{$i} = $handle;
                sleep (1);
                print "CMD:@cmd\n";
                $r = system (@cmd);
                print "R:$r:$!\n";
                $i++;
        }
        
        return ($r);
}

my $x = &main (@ARGV);
exit ($x);

Reply via email to