Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: Expect package not working on a Power PC machine

by sri75 (Novice)
on Jul 29, 2006 at 18:39 UTC ( [id://564547]=note: print w/replies, xml ) Need Help??


in reply to Re: Expect package not working on a Power PC machine
in thread Expect package not working on a Power PC machine

Hello !!! Thanks for the suggestion. I tried your suggestion and confirmed that after spawn the ssh session, the expect object is not getting the password prompt. I think that the problem is with the EXPECT package itself. I think the package doesn't work on the PPC machines. After installing the perl EXPECT package, I attempted the run the tests that are provided as part of the package and the very first test itself failed. Check out the below !!!
root@F101-8:/tmp/perl-modules/Expect-1.18# ls Changes Expect.pod META.yml Makefile.PL blib pm_to_blib tu +torial Expect.pm MANIFEST Makefile README examples test.pl root@F101-8:/tmp/perl-modules/Expect-1.18# root@F101-8:/tmp/perl-modules/Expect-1.18# perl Makefile.PL Writing Makefile for Expect root@F101-8:/tmp/perl-modules/Expect-1.18# make Manifying blib/man3/Expect.3 root@F101-8:/tmp/perl-modules/Expect-1.18# make test PERL_DL_NONLAZY=1 /usr/bin/perl "-Iblib/lib" "-Iblib/arch" test.pl 1..36 Basic tests... ok 1 Use of uninitialized value in numeric eq (==) at test.pl line 37. not ok 2 # Test failed at test.pl line 22. Died at test.pl line 22. make: *** [test_dynamic] Error 255 root@F101-8:/tmp/perl-modules/Expect-1.18#
Does any one know how to fix the issue in the Perl Expect Package? Or is there a way to bring up the issue on CPAN. Thanks Sri

Replies are listed 'Best First'.
Re^3: Expect package not working on a Power PC machine
by sri75 (Novice) on Jul 29, 2006 at 18:45 UTC
    Hello !!! I forgot to attach the result from the suggestion using the $session->exp_internal(1);
    root@F101-8:~# cat test.pl #!/usr/bin/perl5.8.4 use Expect; my $timeout = 5; $session = new Expect; $session->exp_internal(1); #$session->debug(3); $session->spawn("ssh 666.666.666.666 -l root\r"); $session->expect($timeout, "password:"); $session->send("wibbilwobble\r"); $session->expect($timeout, "F101"); $session->send("\r"); $session->expect($timeout, "F101"); $session->send("exit\r"); $session->expect($timeout, "F101"); root@F101-8:~# root@F101-8:~# root@F101-8:~# perl test.pl 'pawned 'ssh 666.666.666.666 -l root spawn id(3) Pid: 20277 Tty: /dev/pts/2 Expect::spawn('Expect=GLOB(0x1028abbc)', 'ssh 666.666.666.666 +-l root\x{d}') called at test.pl line 9 Starting EXPECT pattern matching... Expect::expect('Expect=GLOB(0x1028abbc)', 5, 'password:') call +ed at test.pl line 10 spawn id(3): list of patterns: #1: -ex `password:' spawn id(3): Does `' match: pattern #1: -ex `password:'? No. Sending 'wibblewobble\r' to spawn id(3) Expect::print('Expect=GLOB(0x1028abbc)', 'wibblewobble\x{d}') +called at test.pl line 11 Starting EXPECT pattern matching... Expect::expect('Expect=GLOB(0x1028abbc)', 5, 'F101') called at + test.pl line 12 spawn id(3): list of patterns: #1: -ex `F101' spawn id(3): Does `' match: pattern #1: -ex `F101'? No. Sending '\r' to spawn id(3) Expect::print('Expect=GLOB(0x1028abbc)', '\x{d}') called at te +st.pl line 13 Starting EXPECT pattern matching... Expect::expect('Expect=GLOB(0x1028abbc)', 5, 'F101') called at + test.pl line 14 spawn id(3): list of patterns: #1: -ex `F101' spawn id(3): Does `' match: pattern #1: -ex `F101'? No. Sending 'exit\r' to spawn id(3) Expect::print('Expect=GLOB(0x1028abbc)', 'exit\x{d}') called a +t test.pl line 15 Starting EXPECT pattern matching... Expect::expect('Expect=GLOB(0x1028abbc)', 5, 'F101') called at + test.pl line 16 spawn id(3): list of patterns: #1: -ex `F101' spawn id(3): Does `' match: pattern #1: -ex `F101'? No. root@F101-8:~#
    Thanks Sri

    IP address and password changed to protect the inocent (GrandFather)

      Hi again, sri75,

      If I'm interpreting your results correctly, it looks like the Expect object is getting back a blank line:

      spawn id(3): Does `' match: pattern #1: -ex `password:'? No.

      Can you try to get past that by "Expect"ing a newline, prior to the password prompt?

      Or, alternatively (and this might actually be even simpler), try doing it "by hand" (meaning that you should try typing ssh 6.6.6.6 -l root\r at the shell prompt), and see if there's an extra newline (or something similar), which you need to anticipate receiving first.

      Let me know happens when you do either of these steps ...

      Update:  Changed the IP address as per eXile's suggestion.  I won't change it to 666.666.666.666, as that isn't a valid IP address ;-)


      s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/
        Hello !!! I manually executed each of the steps in the scripts and it worked. I also ran the exact same script from a Linux m/c on x86 processor, in which I logined in to the Linux m/c with ppc processor using ssh and it works. It is possible that the issue is not with EXPECT but with the PTY package that EXPECT uses, any comments?? I have already tried replacing \r with \n and that didn't work either. Thanks Sri ============ ON A PPC M/C ============
        root@F101-8:~# uname -a Linux F101-8 2.6.10_mvlcge401-atca_f101 #25 Thu Jun 29 16:07:19 CDT 20 +06 ppc GNU/Linux root@F101-8:~# root@F101-8:~# root@F101-8:~# cat test.pl #!/usr/bin/perl5.8.4 use Expect; my $timeout = 5; $session = new Expect; #$session->exp_internal(1); #$session->debug(3); $session->spawn("ssh 10.20.30.40 -l root\n"); $session->expect($timeout, "password:"); $session->send("pirates\n"); $session->expect($timeout, "F101"); $session->send("\n"); $session->expect($timeout, "F101"); $session->send("exit\n"); $session->expect($timeout, "F101"); root@F101-8:~# root@F101-8:~# root@F101-8:~# ssh 10.20.30.40 -l root root@10.20.30.40's password: Last login: Sun Jul 30 14:17:37 2006 from 10.17.194.85 ------------------------------------- Build View: tmproot_r6.1_dev-633914 ABC Version: GGGGG-ABC_R6.1_REL-02 HHH Version: HHH-BASE_R3.3_REL-01.01 NNNN Install Date: Fri Jul 28 22:38:37 UTC 2006 ------------------------------------- root@F101-8:~# exit logout Connection to 10.20.30.40 closed. root@F101-8:~# root@F101-8:~# exit logout Connection to 10.20.30.40 closed. groovy::testuser>
        ================== ON A Intel x86 M/C Note that I am logining in to the PPC m/c from the intel m/c ==================
        groovy::testuser> groovy::testuser> ssh 30.40.50.60 -l root root@30.40.50.60's password: Last login: Fri Jul 28 08:23:34 2006 from dosim3-1 ------------------------------------- Build View: testuser_tmp-evtfil ABC Version: GGGGG-ABC_R6.1_REL-02 HHH Version: HHH-BASE_R3.3_REL-01.01 NNNN Install Date: Thu Jul 27 11:15:02 CDT 2006 ------------------------------------- root@dosim3-1:~# uname -a Linux dosim3-1 2.6.10_mvlcge401-pc_target-x86_pentium4 #1 SMP Sun Sep +25 19:32:17 PDT 2005 i686 GNU/Linux root@dosim3-1:~# root@dosim3-1:~# root@dosim3-1:~# cat test.pl #!/usr/bin/perl5.8.4 use Expect; my $timeout = 5; $session = new Expect; $session->exp_internal(1); $session->spawn("ssh 10.20.30.40 -l root\r"); $session->expect($timeout, "password:"); $session->send("pirates\r"); $session->expect($timeout, "F101"); $session->send("\r"); $session->expect($timeout, "F101"); $session->send("exit\r"); root@dosim3-1:~# root@dosim3-1:~# root@dosim3-1:~# root@dosim3-1:~# perl test.pl Spawned 'ssh 10.20.30.40 -l root' spawn id(3) Pid: 22211 Tty: /dev/pts/2 Expect::spawn('Expect=GLOB(0x82a0fa8)', 'ssh 10.20.30.40 -l ro +ot\x{d}') called at test.pl line 8 Starting EXPECT pattern matching... Expect::expect('Expect=GLOB(0x82a0fa8)', 5, 'password:') calle +d at test.pl line 9 spawn id(3): list of patterns: #1: -ex `password:' spawn id(3): Does `' match: pattern #1: -ex `password:'? No. root@10.20.30.40's password: spawn id(3): Does `root@10.20.30.40\'s password: ' match: pattern #1: -ex `password:'? YES!! Before match string: `root@10.20.30.40\'s ' Match string: `password:' After match string: ` ' Matchlist: () Sending 'pirates\r' to spawn id(3) Expect::print('Expect=GLOB(0x82a0fa8)', 'pirates\x{d}') called + at test.pl line 10 Starting EXPECT pattern matching... Expect::expect('Expect=GLOB(0x82a0fa8)', 5, 'F101') called at +test.pl line 11 spawn id(3): list of patterns: #1: -ex `F101' spawn id(3): Does ` ' match: pattern #1: -ex `F101'? No. spawn id(3): Does ` \r\n' match: pattern #1: -ex `F101'? No. Last login: Sun Jul 30 14:40:39 2006 from 30.40.50.60 ------------------------------------- Build View: tmproot_r6.1_dev-633914 ABC Version: GGGGG-ABC_R6.1_REL-02 HHH Version: HHH-BASE_R3.3_REL-01.01 NNNN Install Date: Fri Jul 28 22:38:37 UTC 2006 ------------------------------------- spawn id(3): Does ` \r\nLast login: Sun Jul 30 14:40:39 2006 from 30.4 +0.50.60\r\r\n\r\n-------------------------------------\r\nBuild View: + tmproot_r6.1_dev-633914\r\nABC Version: GGG +GG-ABC_R6.1_REL-02 \r\nHHH Version: HHH-BASE_R3.3_REL-01. +01\r\nNNNN Install Date: Fri Jul 28 22:38:37 UTC 2006\r\n------ +-------------------------------\r\n' match: pattern #1: -ex `F101'? No. root@F101-8:~# spawn id(3): Does ` \r\nLast login: Sun Jul 30 14:40:39 2006 from 30.4 +0.50.60\r\r\n\r\n-------------------------------------\r\nBuild View: + tmproot_r6.1_dev-633914\r\nABC Version: GGG +GG-ABC_R6.1_REL-02 \r\nHHH Version: HHH-BASE_R3.3_REL-01. +01\r\nNNNN Install Date: Fri Jul 28 22:38:37 UTC 2006\r\n------ +-------------------------------\r\nroot@F101-8:~# ' match: pattern #1: -ex `F101'? YES!! Before match string: ` \r\nLast login: Sun Jul 30 14:40:39 2006 fr +om 30.40.50.60\r\r\n\r\n-------------------------------------\r\nBuil +d View: tmproot_r6.1_dev-633914\r\nABC Version: + GGGGG-ABC_R6.1_REL-02 \r\nHHH Version: HHH-BASE_R3.3_ +REL-01.01\r\nNNNN Install Date: Fri Jul 28 22:38:37 UTC 2006\r\ +n-------------------------------------\r\nroot@' Match string: `F101' After match string: `-8:~# ' Matchlist: () Sending '\r' to spawn id(3) Expect::print('Expect=GLOB(0x82a0fa8)', '\x{d}') called at tes +t.pl line 12 Starting EXPECT pattern matching... Expect::expect('Expect=GLOB(0x82a0fa8)', 5, 'F101') called at +test.pl line 13 spawn id(3): list of patterns: #1: -ex `F101' spawn id(3): Does `-8:~# ' match: pattern #1: -ex `F101'? No. spawn id(3): Does `-8:~# \r\n' match: pattern #1: -ex `F101'? No. root@F101-8:~# spawn id(3): Does `-8:~# \r\nroot@F101-8:~# ' match: pattern #1: -ex `F101'? YES!! Before match string: `-8:~# \r\nroot@' Match string: `F101' After match string: `-8:~# ' Matchlist: () Sending 'exit\r' to spawn id(3) Expect::print('Expect=GLOB(0x82a0fa8)', 'exit\x{d}') called at + test.pl line 14 root@dosim3-1:~# root@dosim3-1:~# root@dosim3-1:~#

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://564547]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-24 01:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found