Re: [Ssh-sftp-perl-users] Problem getting output using Net::SSH2
Brought to you by:
dbrobins
From: Steve P. <st...@fo...> - 2011-05-06 01:24:39
|
On 5/05/2011 5:43 PM, Thierry Chich wrote: > Le 05/05/2011 07:30, Fitzpatrick, Robert M (Rob) a écrit : >> If I manually ssh into the remote box and run the command it returns >> values as expected, and if I do something similar using Net::SSH::Perl >> it works as well, however, Net::SSH::Perl seems to take upward of 30 >> seconds to create a connection which isn't an option in this environment >> (and yeah - I've tried all the math module stuff which didn't seem to >> make a difference:-( ) > Hello, > > There is a very good alternative to Net::SSH::Perl. It is Net::OpenSSH. > It is using openssh, but it is a very good implantation. It is working > well, it implement scp, sftp, channel. > But I am quite sure that connecting in 30 second is not a normal > behavior. The dependancies of Net::SSH::Perl are painfull. I never > remember if it is Math::BigInt that accelerate the whole thing, or a > GMP::*. I see that you think that you have installed all this stuff, but > I think you should check this an other time. Yeah, I spent quite a bit of time trying to figure out why this took so long. I had the Math::BigInt::GMP module installed - which people advised would speed things up and for some reason it took even longer (I gave up waiting after around 1:30 per connection) and also had Math::GMP installed with no discernible improvements. I had decided that it was possibly a version problem (this was running on a Redhat 9 box, don't ask) and so put a new, more powerful system in (CentOS 5, with an i7 CPU) and re-installed Net::SSH::Perl along with most dependencies (I think I was missing one of the Crypt modules that caused it to burp at private key auth using DSA) but the connection side of things still took over 30 seconds. (this is the initial key exchange sequence that seems to take this long) All this was using pre compiled packages as well, as compiling isn't really an option due to the system it's going to end up on (well, it COULD be but would require a lot more effort than simply switching to something that works out of the box :-) ) At that point I gave up and found Net::SSH2 which using the compiled library is stupidly fast in comparison, but now have this output problem that is semi solved (thanks Rob) and just have to figure out how to tell when there is data waiting to be read off the filehandle so I don't have to use random sleep timers. At this point I'm contemplating a loop using usleep but this seems like a bit of a hack - when spawning a shell to run your commands, is there really no way to block until the command has exited or do you have to find other ways of figuring out the exit state of the last passed command (like running $command and then a 'whoami' and read input until you come across the username on a single line - seems a little much) -- Steve. |