Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Expect package not working on a Power PC machine

by liverpole (Monsignor)
on Jul 29, 2006 at 16:13 UTC ( [id://564540]=note: print w/replies, xml ) Need Help??


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

Hi sri75,

Have you tried setting $object->exp_internal(1)?  I have often had success with that when I need to know exactly what Expect is getting back from the spawned process.


s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/
  • Comment on Re: Expect package not working on a Power PC machine

Replies are listed 'Best First'.
Re^2: Expect package not working on a Power PC machine
by sri75 (Novice) on Jul 29, 2006 at 18:39 UTC
    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
      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$..$/

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (1)
As of 2024-04-25 02:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found