Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Expect Module problem

by Paladin (Priest)
on Jul 13, 2004 at 21:48 UTC ( #374155=note: print w/replies, xml ) Need Help??


in reply to Expect Module problem

Well, you aren't doing anything after spawning the process, so the script is ending and killing the process. Try the following:
use Expect; $Expect::Debug = 1; my $string= '/usr/bin/ssh 127.0.0.1'; my $exp=Expect->spawn($string) || die "error $!\n"; $exp->expect(2, "password: "); $exp->send("XXXXXXXX\n"); $exp->expect(2,'$'); $exp->send("ls\n"); $exp->expect(2,'$');
This works fine on my system.

Update:

If your goal is to interact with the ssh session after scripting the login, try adding:

$exp->interact();
after you have finished logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://374155]
help
Chatterbox?
[Corion]: Hi marto!
[marto]: hey Corion, good weekend?
[Corion]: marto: Yeah, even though I didn't write any code :)
[Corion]: But at least I have a plan of action to move the site to https, played some (free!) VR games with friends and watched the plans for the next German Perl workshop progress ;)

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (10)
As of 2017-08-21 09:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Who is your favorite scientist and why?



























    Results (319 votes). Check out past polls.

    Notices?