J
jrpfinch
Dear gurus,
Please could somebody give me a hint as to why this script at the
bottom of this post does not work when I remove the nofork=>1 from
line 19? When I remove it (i.e. the scheduler becomes a forking
scheduler), checkMsMessages works the first time, but the second time
I get an error:
bash-2.05# /opt/perl5.8.8/bin/perl distill2.pl
Scheduling started...
stdout is beatbox
Bad packet length 1879469963 at /opt/perl5.8.8/lib/site_perl/5.8.8/Net/
SSH/Perl/Packet.pm line 175
Ultimately I would like the scheduler to be forking because it will
have multiple entries all happening at similar times. Any tips on how
to achieve this would be appreciated. Setting up an SSH login every
time checkMsMessages is called would be expensive, so I would like to
avoid this.
Many thanks
Jon
use strict;
use warnings;
use Net::SSH:
erl;
use Schedule::Cron;
main();
sub main
{
my $cron = new Schedule::Cron(\&dispatchDefault);
my $conn;
$conn = Net::SSH:
erl -> new ("10.xxx.xxx.xxx", protocol => 2);
$conn->login("user","password");
$cron->add_entry("* * * * * 30", { 'subroutine' =>
\&checkMsMessages,
'arguments' =>
[$conn]});
print "Scheduling started...\n";
$cron->run(nofork=>1);
}
sub checkMsMessages
{
my $currentConnRef = $_[0];
my ($stdout, $stderr, $exit);
($stdout, $stderr, $exit) =
$currentConnRef->cmd
('echo beatbox');
chomp ($stdout);
print "stdout is $stdout\n";
}
sub dispatchDefault
{
print "ID: ",shift,"\n";
print "Args: ","@_","\n";
die "Functionshould never be called."
}
__END__
Please could somebody give me a hint as to why this script at the
bottom of this post does not work when I remove the nofork=>1 from
line 19? When I remove it (i.e. the scheduler becomes a forking
scheduler), checkMsMessages works the first time, but the second time
I get an error:
bash-2.05# /opt/perl5.8.8/bin/perl distill2.pl
Scheduling started...
stdout is beatbox
Bad packet length 1879469963 at /opt/perl5.8.8/lib/site_perl/5.8.8/Net/
SSH/Perl/Packet.pm line 175
Ultimately I would like the scheduler to be forking because it will
have multiple entries all happening at similar times. Any tips on how
to achieve this would be appreciated. Setting up an SSH login every
time checkMsMessages is called would be expensive, so I would like to
avoid this.
Many thanks
Jon
use strict;
use warnings;
use Net::SSH:
use Schedule::Cron;
main();
sub main
{
my $cron = new Schedule::Cron(\&dispatchDefault);
my $conn;
$conn = Net::SSH:
$conn->login("user","password");
$cron->add_entry("* * * * * 30", { 'subroutine' =>
\&checkMsMessages,
'arguments' =>
[$conn]});
print "Scheduling started...\n";
$cron->run(nofork=>1);
}
sub checkMsMessages
{
my $currentConnRef = $_[0];
my ($stdout, $stderr, $exit);
($stdout, $stderr, $exit) =
$currentConnRef->cmd
('echo beatbox');
chomp ($stdout);
print "stdout is $stdout\n";
}
sub dispatchDefault
{
print "ID: ",shift,"\n";
print "Args: ","@_","\n";
die "Functionshould never be called."
}
__END__