From: Ron S. <gee...@ya...> - 2009-03-29 00:03:58
|
Hi all, I just need to start an app that asks for a password from a script. I'm 'ssh'ing in from another box, but I've got that part covered with 'Net::SSH::Perl'. I'm a little confused as to how/if I should use 'Expect'. My 'ExtUtils::Installed' list shows 'Net::SSH::Perl', 'Expect' and 'IO::Tty'. I think I have everything I need. The script I have so far is as follows: #!/usr/bin/perl use warnings; use strict; use Net::SSH::Perl; my $host = "someHost"; my $sshConn = Net::SSH::Perl->new($host, port => 22); $sshConn->login("someUserName", "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.\n\n"; } else { print "\n'someProcess' is UP and running.\n\n"; } $sshConn->cmd("exit"); What I have, so far, works. But, I think I need 'Expect' to negotiate the password to 'someProcess' (no username will be asked for by the process). I'd put this after the line: print "\n'someProcess' is DOWN and not running.\n\n"; Can anyone help clear up my confusion? I'm almost there. TIA, Ron Smith gee...@ya... |