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-24 10:27:45
|
Hi Mark, The result is same when I used Net::SSH::Perl instaead of W32Perl. I have commented out the "fcntl" call in C:\Perl\Site\lib\Net\SSH\Perl.pm to work proprely in my windows PC. When I say $ssh->cmd("ls -al > x") in my code, this command got executed on the remote host. But prgram is getting stucked there and not executing the next perl instructions in the file. If possible, please let me know why the program is getting stucked at $ssh->cmd. Thanks & Regards, Rishi -----Original Message----- From: Mark A. Fuller [mailto:mar...@ea...] Sent: Tuesday, March 23, 2004 11:18 PM To: Rishi Kaundinya M; 'Mark A. Fuller'; ssh...@li... Subject: RE: [Ssh-sftp-perl-users] RE: (Urgent) Information required on Net::SSH::W32Perl package Hi Rishi, It's hard to say since you are using Net::SSH::W32Perl which is a clone of Net::SSH::Perl from 2 years ago. Did you try contacting the maintainer of it? Did you try using Net::SSH::Perl to see if it exhibits the same problem? Assuming they are not too disimiliar, what do you get from ($out, $err, $exit) returned from the cmd method? Anything? I would try the shell method and do some things interactively to see if it behaves differently. It sounds like you're saying any commands fail. First it was "ls". Now "exit"? Do any commands work? Have you tried using a native SSH (binary like openSSH) just to see if you can get ssh to work this way? (rule out the possibility it's something wrong with the sshd server). But again, you're using a distribution that may be significantly different from Net::SSH::Perl. Mark -----Original Message----- From: Rishi Kaundinya M <kau...@in...> Sent: Mar 23, 2004 9:50 AM To: "'Mark A. Fuller'" <mar...@ea...>, ssh...@li... Subject: RE: [Ssh-sftp-perl-users] RE: (Urgent) Information required on Net::SSH::W32Perl package Hi Mark, I have written small test program 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); $ssh->cmd("exit"); print "\n Hi Rishi"; ============================================================================ ========== I got the following output. As you see the the program is not terminating and the I am not seeing "Hi Rishi" in the standard output. The program got stuck at the following point. <snip> channel 1: open confirm rwindow 0 rmax 32768 </snip> Can you please tell me what I need to do inorder the control to reach to print statement following $ssh->cmd("exit"). I am facing the same behaviour even though I did regoster_handler for the commands. I got stucked at this point in my project and need this information urgently. I appreciate your help in this regard. ============================================================================ =========== D:\Projects\console_logger\SSH\Test>perl ex1.pl eb96140: Reading configuration data /.ssh/config eb96140: Reading configuration data /etc/ssh_config eb96140: Connecting to sama.india.hp.com, port 22. eb96140: Socket created, turning on blocking... eb96140: Remote protocol version 2.0, remote software version OpenSSH_3.7.1p2-pw exp26 eb96140: Net::SSH::Perl Version 1.25, protocol version 2.0. eb96140: No compat match: OpenSSH_3.7.1p2-pwexp26. eb96140: Connection established. eb96140: Sent key-exchange init (KEXINIT), wait response. eb96140: Algorithms, c->s: 3des-cbc hmac-sha1 none eb96140: Algorithms, s->c: 3des-cbc hmac-sha1 none eb96140: Entering Diffie-Hellman Group 1 key exchange. eb96140: Sent DH public key, waiting for reply. eb96140: Received host key, type 'ssh-dss'. eb96140: Computing shared secret key. eb96140: Verifying server signature. eb96140: Waiting for NEWKEYS message. eb96140: Enabling incoming encryption/MAC/compression. eb96140: Send NEWKEYS, enable outgoing encryption/MAC/compression. eb96140: Sending request for user-authentication service. eb96140: Service accepted: ssh-userauth. eb96140: Trying empty user-authentication request. eb96140: Authentication methods that can continue: publickey,password,keyboard-i nteractive. 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: exit eb96140: Requesting service exec on channel 1. eb96140: channel 1: open confirm rwindow 0 rmax 32768 ============================================================================ ====== Thanks & Regards, Rishi -----Original Message----- From: ssh...@li... [mailto:ssh...@li...]On Behalf Of Mark A. Fuller Sent: Tuesday, March 23, 2004 9:28 PM To: Rishi Kaundinya M; 'Mark Fuller'; ssh...@li... Subject: RE: [Ssh-sftp-perl-users] RE: (Urgent) Information required on Net::SSH::W32Perl package Rishi, regarding question #4, I think "exit" would be an appropriate way to terminate the secure shell. You're telling the remote host you're exiting and it will close the connection? Regarding your other questions: how different is Net::SSH::W32Perl? I just read about it on CPAN and it says it is a copy of Net::SSH::Perl from early 2002. Maybe it behaves differently? Have you tried to contact the author (Scott Scecina, as listed on the CPAN page)? You could try the same commands using Net::SSH::Perl and see if it fails too. Mark -----Original Message----- From: Rishi Kaundinya M <kau...@in...> Sent: Mar 23, 2004 7:26 AM To: 'Mark Fuller' <mar...@ea...>, ssh...@li... Subject: RE: [Ssh-sftp-perl-users] RE: (Urgent) Information required on Net::SSH::W32Perl package 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 ------------------------------------------------------- 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 ------------------------------------------------------- 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 ------------------------------------------------------- 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 |