RE: [Ssh-sftp-perl-users] RE: (Urgent) Information required on Net::SSH::W32Perl package
Brought to you by:
dbrobins
From: Rishi K. M <kau...@in...> - 2004-03-23 14:26:22
|
Hi Mark, Thanks for the reply. Can you tell me why I am unable capture the output of "ls -al" in $out. Also after executing ssh->cmd, the code is stucking and the control is not going to the next statement following $ssh->cmd. Can you explain what I need to do for the script to contrinue executing all the instructions. Regards, Rishi -----Original Message----- From: Mark Fuller [mailto:mar...@ea...] Sent: Tuesday, March 23, 2004 7:38 PM To: Rishi Kaundinya M; ssh...@li... Subject: Re: [Ssh-sftp-perl-users] RE: (Urgent) Information required on Net::SSH::W32Perl package I think what you are asking is how to trap errors and handle them without the script terminating? I had the same problem with Net::SFTP which uses the SSH module. My solution is described in a previous posting which can be found in the archive. http://sourceforge.net/mailarchive/forum.php?thread_id=3823363&forum_id=3651 4 You can process the @warnings array and take actions based on errors you recognize. Retry and write failures to a log, etc. Mark ----- Original Message ----- From: "Rishi Kaundinya M" <kau...@in...> To: <ssh...@li...> Sent: Tuesday, March 23, 2004 6:41 AM Subject: [Ssh-sftp-perl-users] RE: (Urgent) Information required on Net::SSH::W32Perl package > > > -----Original Message----- > From: Rishi Kaundinya M [mailto:kau...@in...] > Sent: Tuesday, March 23, 2004 6:51 PM > To: 'ssh...@li...' > Subject: (Urgent) Information required on Net::SSH::W32Perl package > > 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 |