Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Expect package not working on a Power PC machine

by sri75 (Novice)
on Jul 28, 2006 at 20:25 UTC ( #564449=perlquestion: print w/replies, xml ) Need Help??

sri75 has asked for the wisdom of the Perl Monks concerning the following question:

Hello !!!

I need some help with debugging a problem I ran in to using the PERL EXPECT package. I downloaded the package Expect-1.18 from the CPAN website and installed in on a Linux Machine with a x86 processor. I was successfully able to compile and install the package. I wrote up a simple problem to test it was it worked as expected.

However when I attempted to do the same on a Linux machine with a PowerPC processor, I ran into a problem. Below is the simple program that I was using:

#!/usr/bin/perl5.8.4 use Expect; my $timeout = 5; $session = new Expect; #$session->debug(3); $session->spawn("ssh 666.666.666.666 -l root\r"); $session->expect($timeout, "password:"); $session->send("wibblewobble\r"); $session->expect($timeout, "F101"); $session->send("\r"); $session->expect($timeout, "F101"); $session->send("exit\r"); $session->expect($timeout, "F101");

On the PPC machines, I noticed that the spawn cmd did go through as I was able to see an SSH session using the "netstat -a" cmd. However using debugs I noticed that for some reason the script was not receiving anything back from the command.

Does any one know how to fix this??

Thanks

Sri

20060728 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips

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

Replies are listed 'Best First'.
Re: Expect package not working on a Power PC machine
by liverpole (Monsignor) on Jul 29, 2006 at 16:13 UTC
    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$..$/
      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)

Re: Expect package not working on a Power PC machine
by eXile (Priest) on Jul 29, 2006 at 23:56 UTC
    Hi,

    The IP-address, username and password in your example look pretty real. For showing examples of code it would be best if you obfuscated them in such manner that others would immediately see they are fake/example ones. There are a lot of people on the Internet that would actually try that combination of IP/username/passwd.

    Some IMHO good examples would be:

    • IP-addresses: 1.1.1.1, 10.10.10.10
    • hostname: example.com
    • password: fakepasswd, examplepasswd
    • username: johndoe, joeuser, exampleuser

    As for your actual problem: try replacing the '\r' with '\n', since that is the end of line character for UNIXes.

      Thanks for pointing it out. Appreciate it. --Sri

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://564449]
Approved by Joost
Front-paged by planetscape
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2021-09-18 04:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?