Re: [Ssh-sftp-perl-users] quick question with regard to exec, take 2
Brought to you by:
dbrobins
From: Jeremy K. <ki...@sc...> - 2009-04-03 21:58:08
|
Thierry CHICH wrote: > Jeremy Kitchen a écrit : >> I'm trying to write a quick program which will execute a series of >> commands on the remote system and get each individual exit status back >> from the commands. >> >> It appears the way to go about doing this is to create a new channel, >> exec, get the exit status, destroy the channel, exec, get the exit >> status, etc. >> >> However, I *also* want to grab the output of these commands (stdout and >> stderr) in real time, so I'm trying to use poll. >> >> Now, I could be going about this completely the wrong way. If I am, >> please let me know :) >> >> > I don't know if you are going the wrong way. However, I don't > understand why you are not using > ( $out, $err, $exit ) = $ssh->cmd( "$cmd" ); ? > > You can even execute a complete script shell using sthis syntax: > > ( $out, $err, $exit ) = $ssh->cmd( "bash", "$myscrypt" ); > Isn't it simpler ? > I'm not using Net::SSH::Perl, I'm using Net::SSH2. Net::SSH::Perl can't connect to several of our machines, but Net::SSH2 can. Also, using Net::SSH2's ->cmd method still doesn't give me 'real time' reading of the outputs. I *do* want to do something like what ->cmd does eventually, for really stupid easy stuff where we don't really care about the output until it's done (or commands that are *really* quick) but in the mean time I'm trying to get the realtime stuff working. -Jeremy |