inside ssh tunnel (using Net::Openssh), a pty is opened. then an exp object is init to this pty my $exp=Expect->init($pty);
using this object i am trying to run about quite a few commands on remote system. I am using following method. It has two flaws: 1) does not work if $exp->expect(5); line is removed. (This is like a sleep). 2) only waits for 5 seconds, so command which run longer - do not finish before the next command is run. which is a problem (messes up output). useExpect; ... ... foreachmy$cmd (@cmd_array){ $exp->expect(3, [qr/($|#)/ => sub { shift->send("$cmd");}] ); $exp->expect(5); } I would like to send the command and then wait fo rit to finish (lookout for system prompt) and then execute next command in loop. I tried many things/ways, none work. Pl suggest. I posted question here: http://stackoverflow.com/questions/12272191/perl-expect-running-30-commands-remotely/12273286 unfortunately no help yet. thank you. Rajeev