Re: [Ssh-sftp-perl-users] Net::SSH2 example
Brought to you by:
dbrobins
From: Bryan B. <br...@bu...> - 2006-02-13 19:40:08
|
The best I could come up with is this: --- snip ---> use Net::SSH2; my $ssh2 = Net::SSH2->new(); $ssh2->connect("127.0.0.1"); $ssh2->auth(username => scalar getpwuid($<), interact => 1) or die; print "\n"; my $chan = $ssh2->channel(); $chan->shell(); print $chan "uptime\n"; print $chan "who\n"; print "LINE: $_" while <$chan>; <--- end --- The problem is that once you read from the channel, you no longer seem to be able to interact with it. So in the above code, you will see your uptime and who output, but in the following, all you see is your uptime output: --- snip ---> print $chan "uptime\n"; print "LINE: $_" while <$chan>; print "LINE: $_" while <$chan>; print $chan "who\n"; <--- end --- I suppose this is a bug, but its been difficult to get anything more meaningfull then "read operations seem funny". And I just havnt had time to play with it more. I hope this gets you further then you were before. Bryan http://www.sourceforge.net/projects/rover > Hi everyone, > > I'm trying to get Net::SSH2 to work but I'm kinda stuk after the > connection is made. > > Could anyone provide an example on how to set up a connection, give a > remote command, and then read the output of that command(either stdout > or stderr) > > I would also apreciate an example of the use of chan->shell(); on how to > put several commands into that one and how to read the output of those > commands (stderr and stdout again) > > Thanx > Rob > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through log > files > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642 > _______________________________________________ > Ssh-sftp-perl-users mailing list > Ssh...@li... > https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users > |