From: Madrigal, J. A <j.m...@mi...> - 2011-10-11 17:29:23
|
Thanks! $exp->exp_internal(1); Doing the job! -Juan On 10/11/11 12:09 PM, "Roland Giersig" <rgi...@cp...> wrote: >$Expect::Exp_Internal = 1; > >;-) > >2011/10/11 Madrigal, Juan A <j.m...@mi...>: >> Hi Salvador, >> >> You are right it is doing nothing. I removed the telnet code and I end >>up >> with the same result. Looks like I don't need telnet at all. >> >> I'm trying to automate an Xterm session by passing commands with >>expect. I >> was under the impression that telnet was needed >> because that¹s how the clients connect manually. >> >> $exp->log_user(1) >> >> Doesn't seem to be doing anything. Strange. >> >> Thanks! >> Juan >> >> >> On 10/11/11 10:55 AM, "Salvador Fandino" <sfa...@ya...> wrote: >> >>> >>> >>> >>> >>>----- Original Message ----- >>>> From: "Madrigal, Juan A" <j.m...@mi...> >>>> To: Salvador Fandino <sfa...@ya...> >>>> Cc: Matt Zagrabelny <mzagrabe@d.umn.edu> >>>> Sent: Tuesday, October 11, 2011 4:39 PM >>>> Subject: Re: [Expectperl-discuss] Connecting: Net::OpenSSH -> >>>>Net::Telnet -> Expect.pm >>>> >>>>T hanks 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); >>> >>>Are you sure you need to use Net::Telnet? It is doing nothing here. >>> >>>You are just connecting to the server in $host via ssh and then running >>>a >>>shell there that gets finally connected to the Expect object. Is that >>>what you want (from your previous mail I though you wanted to connect to >>>a second server via telnet)? >>> >>>> # 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? >>> >>>try using... >>> >>> $expect->log_user(1) >>> >>>> >>>> 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); >>>>> ... >>>> >> >> >> >>------------------------------------------------------------------------- >>----- >> All the data continuously generated in your IT infrastructure contains a >> definitive record of customers, application performance, security >> threats, fraudulent activity and more. Splunk takes this data and makes >> sense of it. Business sense. IT sense. Common sense. >> http://p.sf.net/sfu/splunk-d2d-oct >> _______________________________________________ >> Expectperl-discuss mailing list >> Exp...@li... >> https://lists.sourceforge.net/lists/listinfo/expectperl-discuss >> |