[Ssh-sftp-perl-users] (Urgent) Information required on Net::SSH::W32Perl package
Brought to you by:
dbrobins
From: Rishi K. M <kau...@in...> - 2004-03-23 13:48:20
|
Hi, I will appreciate your help in this regard. The requirement I have currently is as follows. Connect to a remote machine and based on the output of previous command excute other commands. All the outputs will be stored in a local folder in windows machine. I will be using perl2exe to generate final binary out of my perl script. I have written a script as follows. ========================================================== use Net::SSH::W32Perl; my $host = 'sama.india.hp.com'; my $cmd="ls -al"; my $ssh = new Net::SSH::W32Perl($host, port => 22, debug => 1, protocol => 2); $ssh->login(Rishi, XXXXX); #print "Hello \n", $str; $ssh->register_handler("stderr", sub { my($channel, $buffer) = @_; my $str = $buffer->bytes; print "\n How are you?"; print "\n $str"; exit; }); my ($out, $ err, $exit) = $ssh->cmd($cmd); $ssh->cmd("exit"); ============================================== I need following clarrification from you. 1. How can I detect the failure of login. I have seen following message from the o/p of above code. "Permission denied at ex1.pl line 7". But I am going to lauch the perl2exe binary as daemon which don't have the terminal interaction. So please let me know how to detect the login failure. 2. I got stucked at the following point and unable to capture the output of " ls -al" in $out. I got following output while running the above code. eb96140: Next method to try is publickey. eb96140: Next method to try is password. eb96140: Trying password authentication. eb96140: Login completed, opening dummy shell channel. eb96140: channel 0: new [client-session] eb96140: Requesting channel_open for channel 0. eb96140: channel 0: open confirm rwindow 0 rmax 32768 eb96140: Got channel open confirmation, requesting shell. eb96140: Requesting service shell on channel 0. eb96140: channel 1: new [client-session] eb96140: Requesting channel_open for channel 1. eb96140: Entering interactive session. eb96140: Sending command: ls -al eb96140: Requesting service exec on channel 1. eb96140: channel 1: open confirm rwindow 0 rmax 32768 Where the program is stcued at the above point. Please let me know how to get the output ls -al on sama in my windows script. Also code seems to not entring into the sub routine registered. Please let me know what I need to do to solve the problem. I am facing the same problem when I removed the "register_handler" from my program. 3. Is it possible to execute dependent commands (like cd followed ls -al) from my windows PC using ssh2 package. If so, can you please send me an example code. 4. How to terminate the SSH session. Something like ssh->close is available? Thanks in advance for your help, Regards, Rishi ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click _______________________________________________ Ssh-sftp-perl-users mailing list Ssh...@li... https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users |