Re: [Ssh-sftp-perl-users] Problem using Net::SSH::Perl
Brought to you by:
dbrobins
|
From: Chakresh Y. <cy...@ns...> - 2007-01-12 18:34:49
|
Thanks for prompt reply. I tried this piece of code but cannot see the exit
code on the windows box. The command is successfully executed on the remote
Unix server.
I go to the unix box and stop the service and then perl script exits
successfully.
Does this give any clue what's going on ???
Thanks
Chakresh
-----Original Message-----
From: rkb@i.frys.com [mailto:rkb@i.frys.com]
Sent: Friday, January 12, 2007 9:35 AM
To: cy...@ns...
Cc: ssh...@li...
Subject: Re: [Ssh-sftp-perl-users] Problem using Net::SSH::Perl
Try checking the exit code of the command.
my ($stdout, $stderr, $exit) = $ssh->cmd("service snmpd start");
if ($exit != 0 {
warn "An error has occured - exit code:$exit\nerror message:$stderr";
}
else {
print "ssh command succeeded - Good Bye";
}
> Hi,
>
>
>
> I am running a simple script to execute a command on a remote linux
> server.
> The machine on which pl script is running is windows XP (no cygwin
> installed). Below is the script and output
>
>
>
> #testing script
>
> use Net::SSH::Perl;
>
>
>
> $targetIP = shift;
>
> $userName = shift;
>
> $password = shift;
>
> $sourceFileName = shift;
>
> $destinationDir = shift;
>
>
>
> my $ssh = Net::SSH::Perl->new($targetIP, debug=>1);
>
> $ssh->login($userName,$password);
>
>
>
> $ssh->cmd("service snmpd start");
>
>
>
> print "Bye";
>
>
>
> The debug output is
>
>
>
> ChakreshYadavPC: Reading configuration data /.ssh/config
>
> ChakreshYadavPC: Reading configuration data /etc/ssh_config
>
> ChakreshYadavPC: Connecting to 192.168.1.203, port 22.
>
> ChakreshYadavPC: Remote version string: SSH-1.99-OpenSSH_3.5p1
>
>
>
> ChakreshYadavPC: Remote protocol version 1.99, remote software version
> OpenSSH_3
>
> .5p1
>
> ChakreshYadavPC: Net::SSH::Perl Version 1.30, protocol version 1.5.
>
> ChakreshYadavPC: No compat match: OpenSSH_3.5p1.
>
> ChakreshYadavPC: Connection established.
>
> ChakreshYadavPC: Waiting for server public key.
>
> ChakreshYadavPC: Received server public key (768 bits) and host key (1024
> bits).
>
>
>
> ChakreshYadavPC: Host '192.168.1.203' is known and matches the host key.
>
> ChakreshYadavPC: Encryption type: DES3
>
> ChakreshYadavPC: Sent encrypted session key.
>
> ChakreshYadavPC: Received encryption confirmation.
>
> ChakreshYadavPC: RSA authentication failed: Can't load public key.
>
> ChakreshYadavPC: Doing challenge response authentication.
>
> ChakreshYadavPC: No challenge presented.
>
> ChakreshYadavPC: Trying password authentication.
>
> ChakreshYadavPC: Sending command: service snmpd start
>
> ChakreshYadavPC: Entering interactive session.
>
>
>
>
>
> The scipt does not exit after sending command to remote box. I can see
> service "snmpd" running on remote Unix server but no message "Bye" on
> windows box.
>
>
>
> Does anyone has faced this issue ? Any pointers will be highly appreciated
> as I need this script to run ASAP.
>
>
>
> Thanks
>
> Chakresh
>
>
>
>
>
>
>
>
>
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share
> your
> opinions on IT & business topics through brief surveys - and earn cash
>
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV___
____________________________________________
> Ssh-sftp-perl-users mailing list
> Ssh...@li...
> https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users
>
|