From: Madrigal, J. A <j.m...@mi...> - 2011-10-11 15:17:29
|
On 10/11/11 10:39 AM, "Madrigal, Juan A" <j.m...@mi...> wrote: >Thanks for the help! > >I have it working as follows now: > >use Net::OpenSSH; >use Net::Telnet (); >use Expect; > > ># open ssh connection >$ssh = Net::OpenSSH->new($host, user => $user, passwd => $passwd); >$ssh->error and die "unable to connect to remote server: ". $ssh->error; > >my ($pty, $pid) = $ssh->open2pty(); > > ># open telnet connection over ssh >my $tlc = Net::Telnet->new(fhopen => $pty); > ># pass connection to expect >my $exp = Expect->init($tlc); >$exp->raw_pty(0); >$exp->debug(3); > > >Now the only thing is left is figuring out how to "see" what expect is >doing or get some feed back >on stdout and later I'll need to figure out how to use SSH Keys vs >user/passwd combo as well. > >It seems like my expect code is running, but I can't confirm. Flying >blind. > >The only thing that I notice is that I can throw in an $exp->interact(); >and the result of the last command is spit out to stdout. Though I'm >pretty sure there's a better way to see whats going on while expect code >runs. > >Suggestions? > >Thanks, >Juan > > > >On 10/11/11 1:55 AM, "Salvador Fandino" <sfa...@ya...> wrote: > >> >>>From: "Madrigal, Juan A" <j.m...@mi...> >>>To: "exp...@li..." >>><exp...@li...> >>>Sent: Monday, October 10, 2011 8:35 PM >>>Subject: [Expectperl-discuss] Connecting: Net::OpenSSH -> Net::Telnet -> >>>Expect.pm >>> >>>Hi, >>> >>>I'm new to using expect.pm and I'm have trouble trying to create an ssh >>>tunnel with telnet in the middle then passing expect commands. >>> >>>I.E. >>>Net::OpenSSH -> Net::Telnet -> Expect.pm >>> >>> >> >>If telnet is installed on the SSH gateway, you can use... >> >> my $ssh = Net::OpenSSH->new(...); >> my ($pty, $pid) = $ssh->open2pty(telnet => $host) >> or die "unable to telnet to $host: " . $ssh->error; >> my $expect = Expect->init($pty); >> ... > |