Re: [Ssh-sftp-perl-users] Problem using Net::SSH::Perl
Brought to you by:
dbrobins
From: Chakresh Y. <cy...@ns...> - 2007-01-13 02:06:20
|
Hi Paulo, The command does not hang if executed directly on unix box but give back the prompt. "nohup" does not work either. I tried "service snmpd start &" and it works fine and perl script exits properly. So for unix server I can remotely execute the command now. Now, I am trying to run a similar script to run a batch file on remote windows machine and it hangs with a different message this time. ChakreshYadavPC: Reading configuration data /.ssh/config ChakreshYadavPC: Reading configuration data /etc/ssh_config ChakreshYadavPC: Connecting to 192.168.1.125, port 22. ChakreshYadavPC: Remote version string: SSH-2.0-VShell_2_3_4_234 VShell ChakreshYadavPC: Remote protocol version 2.0, remote software version VShell_2_3 _4_234 VShell ChakreshYadavPC: Net::SSH::Perl Version 1.30, protocol version 2.0. .hakreshYadavPC: No compat match: VShell_2_3_4_234 VShell ChakreshYadavPC: Connection established. ChakreshYadavPC: Sent key-exchange init (KEXINIT), wait response. ChakreshYadavPC: Algorithms, c->s: 3des-cbc hmac-sha1 none ChakreshYadavPC: Algorithms, s->c: 3des-cbc hmac-sha1 none ChakreshYadavPC: Entering Diffie-Hellman Group 1 key exchange. ChakreshYadavPC: Sent DH public key, waiting for reply. ChakreshYadavPC: Received host key, type 'ssh-dss'. ChakreshYadavPC: Host '192.168.1.125' is known and matches the host key. ChakreshYadavPC: Computing shared secret key. ChakreshYadavPC: Verifying server signature. ChakreshYadavPC: Waiting for NEWKEYS message. ChakreshYadavPC: Enabling incoming encryption/MAC/compression. ChakreshYadavPC: Send NEWKEYS, enable outgoing encryption/MAC/compression. ChakreshYadavPC: Sending request for user-authentication service. ChakreshYadavPC: Service accepted: ssh-userauth. ChakreshYadavPC: Trying empty user-authentication request. ChakreshYadavPC: Authentication methods that can continue: password,publickey. ChakreshYadavPC: Next method to try is password. ChakreshYadavPC: Trying password authentication. ChakreshYadavPC: Login completed, opening dummy shell channel. ChakreshYadavPC: channel 0: new [client-session] ChakreshYadavPC: Requesting channel_open for channel 0. ChakreshYadavPC: channel 0: open confirm rwindow 32768 rmax 16384 ChakreshYadavPC: Got channel open confirmation, requesting shell. ChakreshYadavPC: Requesting service shell on channel 0. ChakreshYadavPC: channel 1: new [client-session] ChakreshYadavPC: Requesting channel_open for channel 1. ChakreshYadavPC: Entering interactive session. uncopycleanavPC: Sending command: c: ChakreshYadavPC: Requesting service exec on channel 1. ChakreshYadavPC: channel 1: open confirm rwindow 32768 rmax 16384 Before opening a ssh connection, I am using a windows client (pscp.exe) to create directories and copy some files (it is done with success). Code snippet $CMD = "c:\\pscp.exe -l $userName -pw $password -r $sourceFileName $targetIP:$destinationDir"; system("$CMD"); #start a SSH shell for activation my $ssh = Net::SSH::Perl->new($targetIP, debug=>1); $ssh->login($userName,$password); my ($stdout, $stderr, $exit) = $ssh->cmd("c:\run\runcopyclean"); if ($exit != 0 ){ warn "An error has occured - exit code:$exit\nerror message:$stderr"; } else { print "ssh command succeeded - Good Bye"; $ssh->cmd("exit"); } print ("\nBye"); thanks Chakresh |