Hi there senior and experimented SEO..
I have in trouble with a big shit, on Perl, using the module rsh to connect to a list of remote sites, i have running this code:
[...]
#!/usr/bin/perl
use Net:
ing;
use Net::Ifconfig::Wrapper;
use Net::Rsh;
... ...
PropagateStatus(@NodeList,$ProxyNo);
sub PropagateStatus {
local *listnodes=@_[0];
# Set remote status files to itself as the MasterProgram
local $command = "echo " .$_[1] ." > " .$status_file;
local $rsh_connection=Net::Rsh->new();
foreach (@listnodes) {
chomp($_);
print "RSH access to " ."-$username\@$_- \n";
print "Executing: $command at remote host\n";
@tmp=$rsh_connection->rsh($_,$username,$username,$command);
}
}
ok, this code, makes a rsh connection to a list of available nodes (from a file)
but suddenlly, if one node have crashed the service it still get connected,
and doesnt release from this node to connect to the next... because the module Net::Rsh doesnt have a time out to to that, so i think i have found the solution:
....
local $rsh_connection=Net::Rsh->new();
foreach (@listnodes) {
$SIG{ALRM} = \&temporizador;
$time=15;
eval {
alarm($time);
chomp($_);
print "RSH access to " ."-$username\@$_- \n";
print "Executing: $command at remote host\n";
@tmp=$rsh_connection->rsh($_,$username,$username,$command);
}
}
alarm(0);
};
if ($@ =~ /End of timer/){
print "Returns timer code\n";
}else{
print "Returns no code: $res\n";
}
sub temporizador {
# how its added
die "Timeup of timer";
}
Could someone with high level of Perl please help me add this timer function on this code? Its very usefull for scripts that makes high availability of checking process running on others machines...
*As reward I can share my script with you if you want to use it in private*
Thanks in advance Programming Gurus!
I have in trouble with a big shit, on Perl, using the module rsh to connect to a list of remote sites, i have running this code:
[...]
#!/usr/bin/perl
use Net:
use Net::Ifconfig::Wrapper;
use Net::Rsh;
... ...
PropagateStatus(@NodeList,$ProxyNo);
sub PropagateStatus {
local *listnodes=@_[0];
# Set remote status files to itself as the MasterProgram
local $command = "echo " .$_[1] ." > " .$status_file;
local $rsh_connection=Net::Rsh->new();
foreach (@listnodes) {
chomp($_);
print "RSH access to " ."-$username\@$_- \n";
print "Executing: $command at remote host\n";
@tmp=$rsh_connection->rsh($_,$username,$username,$command);
}
}
ok, this code, makes a rsh connection to a list of available nodes (from a file)
but suddenlly, if one node have crashed the service it still get connected,
and doesnt release from this node to connect to the next... because the module Net::Rsh doesnt have a time out to to that, so i think i have found the solution:
....
local $rsh_connection=Net::Rsh->new();
foreach (@listnodes) {
$SIG{ALRM} = \&temporizador;
$time=15;
eval {
alarm($time);
chomp($_);
print "RSH access to " ."-$username\@$_- \n";
print "Executing: $command at remote host\n";
@tmp=$rsh_connection->rsh($_,$username,$username,$command);
}
}
alarm(0);
};
if ($@ =~ /End of timer/){
print "Returns timer code\n";
}else{
print "Returns no code: $res\n";
}
sub temporizador {
# how its added
die "Timeup of timer";
}
Could someone with high level of Perl please help me add this timer function on this code? Its very usefull for scripts that makes high availability of checking process running on others machines...
*As reward I can share my script with you if you want to use it in private*
Thanks in advance Programming Gurus!