develooper Front page | perl.beginners | Postings from January 2002

using the system function

Thread Next
From:
lospalomares
Date:
January 18, 2002 05:14
Subject:
using the system function
Message ID:
20020116193622.49531.qmail@web20201.mail.yahoo.com
I am trying to scp a file to various systems, but the
script hangs if the scp command to one of the systems
fails.  Is there a way in perl to specify that if the
scp command doesn't work to skip it and continue with
the next system?  I have the following:

:
:
use Net::Ping;

@systems = qw(system1 system2 system3);

foreach $system (@systems) {
   $p = Net::Ping->new("icmp");
   next unless $p->ping($system);  

   system("/usr/local/bin/scp file $system:/home");

   $p->close();
}

--------

This works if the system is not reachable.  But if the
system is reachable but it is hung for some other
reason, the script tries to do the scp command which
it won't work.  So the script does not continue.

Any ideas on this would be greatly appreciated.

Thanks.

__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About