No need to fiddle with Expect, just create a check-script on the remote
side that does the auto-start and call that with 'ssh remote-host
check-script.sh'.
HTH, Roland
Ron Smith wrote:
> The foolowing script is meant to ssh into another machine, check a running script and, if it's not running, start it. I'm stuck at 'Expect->spawn()'. I get: DB<3> p $command Expect=GLOB(0x9a7658c) upon debugging. I'm lost at this point. Any help would be appreciated.
>
>
> #!/usr/bin/perl
>
> use warnings;
> use strict;
>
> use Net::SSH::Perl;
> use Expect;
>
> my $host = "someHost";
> my $sshConn = Net::SSH::Perl->new($host, port => 22);
> $sshConn->login("someUser", "somePassword");
> chomp (my $cmd = 'ps -ef | grep someProcess | grep -v grep');
> my ($out, $err) = $sshConn->cmd($cmd || "ls -l");
> if (!defined $out) {
> print "\n'someProcess' is DOWN and not running. A restart will be attempted.\n\n";
> my $command = Expect->spawn("sudo -u root /usr/local/bin/someProgram")
> or die "Couldn't start program: $!\n";
> sleep 2;
> print $command "somePassword\r";
> $DB::single=2;
> } else {
> print "\n'someProcess' is UP and running.\n\n";
> }
> $sshConn->cmd("exit");
>
>
>
> Ron Smith
> gee...@ya...
> (213)300-9448
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Expectperl-discuss mailing list
> Exp...@li...
> https://lists.sourceforge.net/lists/listinfo/expectperl-discuss
>
|