in reply to Re: Printing Output From Net::SSH2 exec
in thread Printing Output From Net::SSH2 exec
That is not reliable!$chan->shell(); print $chan "ls -la\n"; print "LINE : $_" while <$chan>; print $chan "who\n"; print "LINE : $_" while <$chan>; print $chan "date\n"; print "LINE : $_" while <$chan>;
The remote shell doesn't signal in any way when the commands run through it exit to its parent process, the ssh server. If the remote command does not run fast enough, the ... while(<$chan>) loop will finish without having read the full output, and the remaining data will be delayed until the next loop (or even later).
Net::SSH::Expect that uses a similar approach, solves that problem examining the remote output, looking for the shell prompt in order to detect when a subcommand has finished.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Printing Output From Net::SSH2 exec
by vortura (Initiate) on May 14, 2009 at 19:05 UTC | |
by PiLIT888 (Initiate) on Aug 20, 2009 at 19:44 UTC |