in reply to Re: ssh using expect
in thread ssh using expect
#! /usr/bin/perl use Net::SSH::Expect; my $ssh = Net::SSH::Expect->new ( host=>"xxx", user=>'yyy', timeout=>10, raw_pty=>1 ); $prompt="[Pp]assword"; $ssh->run_ssh(); $ssh->waitfor('qr/\(yes\/no\)\?$/',2); $ssh->send("yes\n"); $ssh->waitfor('qr/$prompt:\s*$/',5); $ssh->send("password"); my $peshlogin=$ssh->exec("su - root\n"); $ssh->waitfor('qr/$prompt:\s*$/',5); $ssh->send("password\n"); my $peshlogin=$ssh->exec('echo $?' . "\n","4"); print "THE LOGIN is $peshlogin\n"; $ssh->close();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: ssh using expect
by tirwhan (Abbot) on Dec 04, 2007 at 19:10 UTC | |
by Anonymous Monk on Jan 12, 2012 at 15:05 UTC |