ssh-sftp-perl-users Mailing List for Net::SSH and Net::SFTP - Perl modules (Page 21)
Brought to you by:
dbrobins
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(6) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(4) |
Feb
(15) |
Mar
(13) |
Apr
(8) |
May
(5) |
Jun
(21) |
Jul
(4) |
Aug
(9) |
Sep
(11) |
Oct
(14) |
Nov
(15) |
Dec
(24) |
2005 |
Jan
(10) |
Feb
(20) |
Mar
(16) |
Apr
(10) |
May
(12) |
Jun
(16) |
Jul
(18) |
Aug
(21) |
Sep
(11) |
Oct
(19) |
Nov
(16) |
Dec
(9) |
2006 |
Jan
(17) |
Feb
(32) |
Mar
(60) |
Apr
(21) |
May
(24) |
Jun
(1) |
Jul
(6) |
Aug
(18) |
Sep
(4) |
Oct
(9) |
Nov
(31) |
Dec
(10) |
2007 |
Jan
(8) |
Feb
(11) |
Mar
(3) |
Apr
(7) |
May
(4) |
Jun
(6) |
Jul
(7) |
Aug
(3) |
Sep
(2) |
Oct
(5) |
Nov
(5) |
Dec
(5) |
2008 |
Jan
(12) |
Feb
(5) |
Mar
(7) |
Apr
(4) |
May
(37) |
Jun
(9) |
Jul
(24) |
Aug
(5) |
Sep
(2) |
Oct
(7) |
Nov
(6) |
Dec
(7) |
2009 |
Jan
(18) |
Feb
(9) |
Mar
(14) |
Apr
(14) |
May
(1) |
Jun
(14) |
Jul
(4) |
Aug
(6) |
Sep
(4) |
Oct
(12) |
Nov
(4) |
Dec
|
2010 |
Jan
|
Feb
(3) |
Mar
|
Apr
(1) |
May
(4) |
Jun
|
Jul
(6) |
Aug
(6) |
Sep
|
Oct
(7) |
Nov
(2) |
Dec
(5) |
2011 |
Jan
(2) |
Feb
|
Mar
|
Apr
(1) |
May
(8) |
Jun
(1) |
Jul
|
Aug
(2) |
Sep
|
Oct
(4) |
Nov
(9) |
Dec
(7) |
2012 |
Jan
(1) |
Feb
(19) |
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
(2) |
Apr
(2) |
May
|
Jun
(5) |
Jul
(3) |
Aug
(1) |
Sep
|
Oct
|
Nov
(6) |
Dec
|
2014 |
Jan
(7) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Ajit <aji...@re...> - 2006-04-20 10:35:06
|
Hi Guys,=0AI have written a small perl script =0A=0A#!/usr/bin/perl=0Ause s= trict;=0Ause Net::SSH::w32Perl;=0Ause Net::SSH::Perl;=0A=0Amy $user =3D "ro= ot";=0Amy $pass =3D "password";=0Amy $host =3D "192.168.0.123";=0Amy $cmd = =3D "ls -lt";=0Amy $ssh =3D Net::SSH::W32Perl->new($host);=0A=0A$ssh->login= ($user, $pass);=0Amy @test =3D $ssh->cmd($cmd);=0Aprint @test; =0A=0A=0AThe= script when executed gives desired output ,=0Abut it gives some additional= messages before giving proper output=0Athese messages are as follows , = =0A=0AIO::Socket::INET at C:/Perl/site/lib/Net/SSH/Perl/SSH2.pm line 295=0A= IO::Socket::INET at C:/Perl/site/lib/Net/SSH/Perl/SSH2.pm line 295=0AIO::So= cket::INET at C:/Perl/site/lib/Net/SSH/Perl/SSH2.pm line 295=0AIO::Socket::= INET at C:/Perl/site/lib/Net/SSH/Perl/SSH2.pm line 295=0AIO::String at C:/P= erl/site/lib/Net/SSH/Perl/Channel.pm line 110=0AIO::Socket::INET at C:/Perl= /site/lib/Net/SSH/Perl/SSH2.pm line 295=0AIO::String at C:/Perl/site/lib/Ne= t/SSH/Perl/Channel.pm line 110=0AIO::Socket::INET at C:/Perl/site/lib/Net/S= SH/Perl/SSH2.pm line 295=0AIO::String at C:/Perl/site/lib/Net/SSH/Perl/Chan= nel.pm line 110=0AIO::String at C:/Perl/site/lib/Net/SSH/Perl/Channel.pm li= ne 118=0AIO::Socket::INET at C:/Perl/site/lib/Net/SSH/Perl/SSH2.pm line 295= =0AIO::String at C:/Perl/site/lib/Net/SSH/Perl/Channel.pm line 110=0AIO::So= cket::INET at C:/Perl/site/lib/Net/SSH/Perl/SSH2.pm line 295=0Atotal 9250= =0Adr-xr-xr-x 52 root root 63168 Apr 20 15:56 proc=0Adrwxrwxrwt = 4 root sys 249 Apr 20 15:55 tmp=0Adrwxr-xr-x 17 root sy= s 4096 Apr 20 11:00 dev=0A-rw-r--r-- 1 root root 13770 = Apr 20 11:00 buildsanity=0Adr-xr-xr-x 6 root root 512 Apr 13 = 14:05 vol=0Adrwxr-xr-x 75 root sys 4096 Apr 13 14:05 etc=0Adr-= xr-xr-x 1 root root 1 Apr 13 14:05 home=0Adr-xr-xr-x 1 ro= ot root 1 Apr 13 14:05 net=0Adrwxr-xr-x 2 root sys = 512 Apr 13 14:03 devices=0Adrwxr-xr-x 2 root root 512 Ap= r 5 15:43 Documents=0Adrwxr-xr-x 40 root sys 1024 Mar 30 11:2= 4 usr=0Adrwxr-xr-x 8 14478 staff 512 Mar 23 16:20 opt=0Adrwxr-x= r-x 6 root root 512 Mar 21 16:55 cdrom=0A-rw-r--r-- 1 root = root 26 Mar 20 14:52 sdm=0Adrwxr-xr-x 2 root root = 512 Mar 20 14:11 Desktop=0A-rw-rw-r-- 1 root gsm 68624 Mar = 3 19:44 Message.log=0Adrwxr-xr-x 11 root sys 512 Mar 2 15:27= mnt=0A-rwxr-xr-x 1 root root 607744 Feb 23 13:27 ssh.tar=0A-rwx= r-xr-x 1 root root 93184 Feb 23 12:45 tar.sh=0Adrwxr-xr-x 2 r= oot root 512 Feb 23 11:16 TT_DB=0Adrwxr-xr-x 41 root sys = 1024 Feb 23 11:12 var=0Adrwxr-xr-x 7 root bin 5120 Feb= 23 10:53 lib=0Adrwxr-xr-x 14 root sys 512 Feb 22 19:12 kerne= l=0Adrwxr-xr-x 2 root sys 1024 Feb 22 19:06 sbin=0Adrwxr-xr-x= 33 root sys 1024 Feb 22 18:38 platform=0Adrwxr-xr-x 4 root = root 512 Feb 22 18:38 system=0Alrwxrwxrwx 1 root root = 9 Feb 22 18:38 bin -> ./usr/bin=0Adrwxr-xr-x 3 root sys = 512 Feb 22 18:37 export=0Adrwx--x--x 2 root root 8192 Feb 2= 2 18:37 lost+found=0A0=0A=0AHow can i overcome these additional messages a= nd "0" after my desired output.=0A=0AThanks=0A~ajit=0A=0AMobile :- 98906717= 07=0D=0A=0D=0A"Success is not the result of spontaneous combustion. You mus= t set yourself on fire." =0D=0A=0D=0A |
From: Michael C. <mac...@gm...> - 2006-04-19 15:08:29
|
All, I am looking to replace all my old network management scripts that use Net::Telnet::Cisco with ones the use Net::SSH::Perl and I need some help interacting with Cisco devices. I am using the script shown below to connec= t to the devices with unsuccessful results. I have included the debug output of a successful session with an OpenSSH client, the corresponding server debug, the debug for the unsuccessful scripted session, and the corresponding server debug for the scripted session. Any insight would be greatly appreciated. Some specs of the Cisco device: Model: WS-C2950-12 (Catalyst 2950 switch 12-port) IOS Image: c2950-i6k2l2q4-mz.121-22.EA7.bin #!/usr/bin/perl use Net::SSH::Perl; use strict; my $ssh =3D Net::SSH::Perl->new( '10.42.150.150', 'protocol' =3D> 2, 'cipher' =3D> '3des-cbc', 'debug' =3D> 1, 'interactive' =3D> 1, ); $ssh->login('networkteam', 'mypassword'); my ($stdout,$stderr,$retval) =3D $ssh->cmd("show version"); print $stdout; =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D Client (OpenSSH) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D [root@localhost ~]# ssh -2 -c 3des-cbc -v -l networkteam 10.42.150.150 OpenSSH_3.9p1, OpenSSL 0.9.7a Feb 19 2003 debug1: Reading configuration data /etc/ssh/ssh_config debug1: Applying options for * debug1: Connecting to 10.42.150.150 [10.42.150.150] port 22. debug1: Connection established. debug1: permanently_set_uid: 0/0 debug1: identity file /root/.ssh/id_rsa type -1 debug1: identity file /root/.ssh/id_dsa type -1 debug1: Remote protocol version 2.0, remote software version Cisco-1.25 debug1: no match: Cisco-1.25 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_3.9p1 debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client 3des-cbc hmac-md5 none debug1: kex: client->server 3des-cbc hmac-md5 none debug1: sending SSH2_MSG_KEXDH_INIT debug1: expecting SSH2_MSG_KEXDH_REPLY debug1: Host '10.42.150.150' is known and matches the RSA host key. debug1: Found key in /root/.ssh/known_hosts2:3 debug1: ssh_rsa_verify: signature correct debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: SSH2_MSG_SERVICE_REQUEST sent debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: password debug1: Next authentication method: password networkteam@10.42.150.150's password: debug1: Authentication succeeded (password). debug1: channel 0: new [client-session] debug1: Entering interactive session. ZNE-WBBA1-2950 AUTHORIZED USERS ONLY ACCESS TO THIS DEVICE IS LOGGED AND MONITORED CONTACT DEPT AUBA NETWORK TEAM ZNE-WBBA1-2950>exit debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 debug1: channel 0: free: client-session, nchannels 1 Connection to 10.42.150.150 closed by remote host. Connection to 10.42.150.150 closed. debug1: Transferred: stdin 0, stdout 0, stderr 89 bytes in 2.1 seconds debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 42.5 debug1: Exit status 0 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D Server (WS-C2950-12) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Apr 19 10:11:09 EDT: SSH0: starting SSH control process Apr 19 10:11:09 EDT: SSH0: sent protocol version id SSH-2.0-Cisco-1.25 Apr 19 10:11:09 EDT: SSH0: protocol version id is - SSH-2.0-OpenSSH_3.9p1 Apr 19 10:11:09 EDT: SSH2 0: send: len 216 (includes padlen 6) Apr 19 10:11:09 EDT: SSH2 0: SSH2_MSG_KEXINIT sent Apr 19 10:11:09 EDT: SSH2 0: ssh_receive: 384 bytes received Apr 19 10:11:09 EDT: SSH2 0: input: packet len 384 Apr 19 10:11:09 EDT: SSH2 0: partial packet 8, need 376, maclen 0 Apr 19 10:11:09 EDT: SSH2 0: input: padlen 9 Apr 19 10:11:09 EDT: SSH2 0: received packet type 20 Apr 19 10:11:09 EDT: SSH2 0: SSH2_MSG_KEXINIT received Apr 19 10:11:09 EDT: SSH2: kex: client->server 3des-cbc hmac-md5 none Apr 19 10:11:09 EDT: SSH2: kex: server->client 3des-cbc hmac-md5 none Apr 19 10:11:09 EDT: SSH2 0: expecting SSH2_MSG_KEXDH_INIT Apr 19 10:11:09 EDT: SSH2 0: ssh_receive: 144 bytes received Apr 19 10:11:09 EDT: SSH2 0: input: packet len 144 Apr 19 10:11:09 EDT: SSH2 0: partial packet 8, need 136, maclen 0 Apr 19 10:11:09 EDT: SSH2 0: input: padlen 5 Apr 19 10:11:09 EDT: SSH2 0: received packet type 30 Apr 19 10:11:09 EDT: SSH2 0: SSH2_MSG_KEXDH_INIT received Apr 19 10:11:09 EDT: SSH2 0: signature length 111 Apr 19 10:11:09 EDT: SSH2 0: send: len 384 (includes padlen 8) Apr 19 10:11:09 EDT: SSH2: kex_derive_keys complete Apr 19 10:11:09 EDT: SSH2 0: send: len 16 (includes padlen 10) Apr 19 10:11:09 EDT: SSH2 0: newkeys: mode 1 Apr 19 10:11:09 EDT: SSH2 0: SSH2_MSG_NEWKEYS sent Apr 19 10:11:09 EDT: SSH2 0: waiting for SSH2_MSG_NEWKEYS Apr 19 10:11:09 EDT: SSH2 0: ssh_receive: 16 bytes received Apr 19 10:11:09 EDT: SSH2 0: input: packet len 16 Apr 19 10:11:09 EDT: SSH2 0: partial packet 8, need 8, maclen 0 Apr 19 10:11:09 EDT: SSH2 0: input: padlen 10 Apr 19 10:11:09 EDT: SSH2 0: newkeys: mode 0 Apr 19 10:11:09 EDT: SSH2 0: received packet type 21 Apr 19 10:11:09 EDT: SSH2 0: SSH2_MSG_NEWKEYS received Apr 19 10:11:09 EDT: SSH2 0: ssh_receive: 48 bytes received Apr 19 10:11:09 EDT: SSH2 0: input: packet len 32 Apr 19 10:11:09 EDT: SSH2 0: partial packet 8, need 24, maclen 16 Apr 19 10:11:09 EDT: SSH2 0: MAC #3 ok Apr 19 10:11:09 EDT: SSH2 0: input: padlen 10 Apr 19 10:11:09 EDT: SSH2 0: received packet type 5 Apr 19 10:11:09 EDT: SSH2 0: send: len 32 (includes padlen 10) Apr 19 10:11:09 EDT: SSH2 0: done calc MAC out #3 Apr 19 10:11:09 EDT: SSH2 0: ssh_receive: 72 bytes received Apr 19 10:11:09 EDT: SSH2 0: input: packet len 56 Apr 19 10:11:09 EDT: SSH2 0: partial packet 8, need 48, maclen 16 Apr 19 10:11:09 EDT: SSH2 0: MAC #4 ok Apr 19 10:11:09 EDT: SSH2 0: input: padlen 9 Apr 19 10:11:09 EDT: SSH2 0: received packet type 50 Apr 19 10:11:09 EDT: SSH2 0: send: len 24 (includes padlen 5) Apr 19 10:11:09 EDT: SSH2 0: done calc MAC out #4 Apr 19 10:11:13 EDT: SSH2 0: ssh_receive: 144 bytes received Apr 19 10:11:13 EDT: SSH2 0: input: packet len 128 Apr 19 10:11:13 EDT: SSH2 0: partial packet 8, need 120, maclen 16 Apr 19 10:11:13 EDT: SSH2 0: MAC #5 ok Apr 19 10:11:13 EDT: SSH2 0: input: padlen 64 Apr 19 10:11:13 EDT: SSH2 0: received packet type 50 Apr 19 10:11:18 EDT: SSH2 0: send: len 16 (includes padlen 10) Apr 19 10:11:18 EDT: SSH2 0: done calc MAC out #5 Apr 19 10:11:18 EDT: SSH2 0: authentication successful for networkteam Apr 19 10:11:18 EDT: SSH2 0: ssh_receive: 56 bytes received Apr 19 10:11:18 EDT: SSH2 0: input: packet len 40 Apr 19 10:11:18 EDT: SSH2 0: partial packet 8, need 32, maclen 16 Apr 19 10:11:18 EDT: SSH2 0: MAC #6 ok Apr 19 10:11:18 EDT: SSH2 0: input: padlen 11 Apr 19 10:11:18 EDT: SSH2 0: received packet type 90 Apr 19 10:11:18 EDT: SSH2 0: channel open request Apr 19 10:11:18 EDT: SSH2 0: send: len 32 (includes padlen 10) Apr 19 10:11:18 EDT: SSH2 0: done calc MAC out #6 Apr 19 10:11:18 EDT: SSH2 0: ssh_receive: 368 bytes received Apr 19 10:11:18 EDT: SSH2 0: input: packet len 312 Apr 19 10:11:18 EDT: SSH2 0: partial packet 8, need 304, maclen 16 Apr 19 10:11:18 EDT: SSH2 0: MAC #7 ok Apr 19 10:11:18 EDT: SSH2 0: input: padlen 5 Apr 19 10:11:18 EDT: SSH2 0: received packet type 98 Apr 19 10:11:18 EDT: SSH2 0: pty-req request Apr 19 10:11:18 EDT: SSH2 0: setting TTY - requested: length 24, width 80; set: length 24, width 80 Apr 19 10:11:18 EDT: SSH2 0: input: packet len 24 Apr 19 10:11:18 EDT: SSH2 0: partial packet 8, need 16, maclen 16 Apr 19 10:11:18 EDT: SSH2 0: MAC #8 ok Apr 19 10:11:18 EDT: SSH2 0: input: padlen 4 Apr 19 10:11:18 EDT: SSH2 0: received packet type 98 Apr 19 10:11:18 EDT: SSH2 0: shell request Apr 19 10:11:18 EDT: SSH2 0: shell message received Apr 19 10:11:18 EDT: SSH2 0: starting shell for vty Apr 19 10:11:18 EDT: SSH2 0: send: len 144 (includes padlen 10) Apr 19 10:11:18 EDT: SSH2 0: done calc MAC out #7 Apr 19 10:11:18 EDT: SSH2 0: send: len 40 (includes padlen 9) Apr 19 10:11:18 EDT: SSH2 0: done calc MAC out #8 Apr 19 10:11:19 EDT: SSH2 0: ssh_receive: 40 bytes received Apr 19 10:11:19 EDT: SSH2 0: input: packet len 24 Apr 19 10:11:19 EDT: SSH2 0: partial packet 8, need 16, maclen 16 Apr 19 10:11:19 EDT: SSH2 0: MAC #9 ok Apr 19 10:11:19 EDT: SSH2 0: input: padlen 9 Apr 19 10:11:19 EDT: SSH2 0: received packet type 94 Apr 19 10:11:19 EDT: SSH2 0: send: len 24 (includes padlen 9) Apr 19 10:11:19 EDT: SSH2 0: done calc MAC out #9 Apr 19 10:11:19 EDT: SSH2 0: ssh_receive: 40 bytes received Apr 19 10:11:19 EDT: SSH2 0: input: packet len 24 Apr 19 10:11:19 EDT: SSH2 0: partial packet 8, need 16, maclen 16 Apr 19 10:11:19 EDT: SSH2 0: MAC #10 ok Apr 19 10:11:19 EDT: SSH2 0: input: padlen 9 Apr 19 10:11:19 EDT: SSH2 0: received packet type 94 Apr 19 10:11:19 EDT: SSH2 0: send: len 24 (includes padlen 9) Apr 19 10:11:19 EDT: SSH2 0: done calc MAC out #10 Apr 19 10:11:20 EDT: SSH2 0: ssh_receive: 40 bytes received Apr 19 10:11:20 EDT: SSH2 0: input: packet len 24 Apr 19 10:11:20 EDT: SSH2 0: partial packet 8, need 16, maclen 16 Apr 19 10:11:20 EDT: SSH2 0: MAC #11 ok Apr 19 10:11:20 EDT: SSH2 0: input: padlen 9 Apr 19 10:11:20 EDT: SSH2 0: received packet type 94 Apr 19 10:11:20 EDT: SSH2 0: send: len 24 (includes padlen 9) Apr 19 10:11:20 EDT: SSH2 0: done calc MAC out #11 Apr 19 10:11:20 EDT: SSH2 0: ssh_receive: 40 bytes received Apr 19 10:11:20 EDT: SSH2 0: input: packet len 24 Apr 19 10:11:20 EDT: SSH2 0: partial packet 8, need 16, maclen 16 Apr 19 10:11:20 EDT: SSH2 0: MAC #12 ok Apr 19 10:11:20 EDT: SSH2 0: input: padlen 9 Apr 19 10:11:20 EDT: SSH2 0: received packet type 94 Apr 19 10:11:20 EDT: SSH2 0: send: len 24 (includes padlen 9) Apr 19 10:11:20 EDT: SSH2 0: done calc MAC out #12 Apr 19 10:11:20 EDT: SSH2 0: ssh_receive: 40 bytes received Apr 19 10:11:20 EDT: SSH2 0: input: packet len 24 Apr 19 10:11:20 EDT: SSH2 0: partial packet 8, need 16, maclen 16 Apr 19 10:11:20 EDT: SSH2 0: MAC #13 ok Apr 19 10:11:20 EDT: SSH2 0: input: padlen 9 Apr 19 10:11:20 EDT: SSH2 0: received packet type 94 Apr 19 10:11:20 EDT: SSH2 0: send: len 24 (includes padlen 8) Apr 19 10:11:20 EDT: SSH2 0: done calc MAC out #13 Apr 19 10:11:20 EDT: SSH2 0: send: len 40 (includes padlen 10) Apr 19 10:11:20 EDT: SSH2 0: done calc MAC out #14 Apr 19 10:11:20 EDT: SSH2 0: send: len 16 (includes padlen 6) Apr 19 10:11:20 EDT: SSH2 0: done calc MAC out #15 Apr 19 10:11:20 EDT: SSH2 0: send: len 16 (includes padlen 6) Apr 19 10:11:20 EDT: SSH2 0: done calc MAC out #16 Apr 19 10:11:20 EDT: SSH0: Session terminated normally =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D Client (Net::SSH::Perl) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D [root@localhost ~]# ./ssh-test.pl localhost.localdomain: Reading configuration data /root/.ssh/config localhost.localdomain: Reading configuration data /etc/ssh_config localhost.localdomain: Allocated local port 1023. localhost.localdomain: Connecting to 10.42.150.150, port 22. localhost.localdomain: Remote protocol version 2.0, remote software version Cisco-1.25 localhost.localdomain: Net::SSH::Perl Version 1.29, protocol version 2.0. localhost.localdomain: No compat match: Cisco-1.25. localhost.localdomain: Connection established. localhost.localdomain: Sent key-exchange init (KEXINIT), wait response. localhost.localdomain: Algorithms, c->s: 3des-cbc hmac-sha1 none localhost.localdomain: Algorithms, s->c: 3des-cbc hmac-sha1 none localhost.localdomain: Entering Diffie-Hellman Group 1 key exchange. localhost.localdomain: Sent DH public key, waiting for reply. localhost.localdomain: Received host key, type 'ssh-rsa'. localhost.localdomain: Host '10.42.150.150' is known and matches the host key. localhost.localdomain: Computing shared secret key. localhost.localdomain: Verifying server signature. localhost.localdomain: Waiting for NEWKEYS message. localhost.localdomain: Enabling incoming encryption/MAC/compression. localhost.localdomain: Send NEWKEYS, enable outgoing encryption/MAC/compression. localhost.localdomain: Sending request for user-authentication service. localhost.localdomain: Service accepted: ssh-userauth. localhost.localdomain: Trying empty user-authentication request. localhost.localdomain: Authentication methods that can continue: password. localhost.localdomain: Next method to try is password. localhost.localdomain: Trying password authentication. localhost.localdomain: Login completed, opening dummy shell channel. localhost.localdomain: channel 0: new [client-session] localhost.localdomain: Requesting channel_open for channel 0. localhost.localdomain: channel 0: open confirm rwindow 1024 rmax 4096 localhost.localdomain: Got channel open confirmation, requesting shell. localhost.localdomain: Requesting service shell on channel 0. localhost.localdomain: channel 1: new [client-session] localhost.localdomain: Requesting channel_open for channel 1. localhost.localdomain: Entering interactive session. localhost.localdomain: Channel open failure: 1: reason 4: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D Server (WS-C2950-12) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Apr 19 10:17:29 EDT: SSH1: starting SSH control process Apr 19 10:17:29 EDT: SSH1: sent protocol version id SSH-2.0-Cisco-1.25 Apr 19 10:17:29 EDT: SSH1: protocol version id is - SSH-2.0-1.29 Apr 19 10:17:29 EDT: SSH2 1: send: len 216 (includes padlen 6) Apr 19 10:17:29 EDT: SSH2 1: SSH2_MSG_KEXINIT sent Apr 19 10:17:30 EDT: SSH2 1: ssh_receive: 176 bytes received Apr 19 10:17:30 EDT: SSH2 1: input: packet len 176 Apr 19 10:17:30 EDT: SSH2 1: partial packet 8, need 168, maclen 0 Apr 19 10:17:30 EDT: SSH2 1: input: padlen 8 Apr 19 10:17:30 EDT: SSH2 1: received packet type 20 Apr 19 10:17:30 EDT: SSH2 1: SSH2_MSG_KEXINIT received Apr 19 10:17:30 EDT: SSH2: kex: client->server 3des-cbc hmac-sha1 none Apr 19 10:17:30 EDT: SSH2: kex: server->client 3des-cbc hmac-sha1 none Apr 19 10:17:30 EDT: SSH2 1: expecting SSH2_MSG_KEXDH_INIT Apr 19 10:17:45 EDT: SSH2 1: ssh_receive: 144 bytes received Apr 19 10:17:45 EDT: SSH2 1: input: packet len 144 Apr 19 10:17:45 EDT: SSH2 1: partial packet 8, need 136, maclen 0 Apr 19 10:17:45 EDT: SSH2 1: input: padlen 5 Apr 19 10:17:45 EDT: SSH2 1: received packet type 30 Apr 19 10:17:45 EDT: SSH2 1: SSH2_MSG_KEXDH_INIT received Apr 19 10:17:45 EDT: SSH2 1: signature length 111 Apr 19 10:17:45 EDT: SSH2 1: send: len 384 (includes padlen 8) Apr 19 10:17:45 EDT: SSH2: kex_derive_keys complete Apr 19 10:17:45 EDT: SSH2 1: send: len 16 (includes padlen 10) Apr 19 10:17:45 EDT: SSH2 1: newkeys: mode 1 Apr 19 10:17:45 EDT: SSH2 1: SSH2_MSG_NEWKEYS sent Apr 19 10:17:45 EDT: SSH2 1: waiting for SSH2_MSG_NEWKEYS Apr 19 10:18:00 EDT: SSH2 1: ssh_receive: 16 bytes received Apr 19 10:18:00 EDT: SSH2 1: input: packet len 16 Apr 19 10:18:00 EDT: SSH2 1: partial packet 8, need 8, maclen 0 Apr 19 10:18:00 EDT: SSH2 1: input: padlen 10 Apr 19 10:18:00 EDT: SSH2 1: newkeys: mode 0 Apr 19 10:18:00 EDT: SSH2 1: received packet type 21 Apr 19 10:18:00 EDT: SSH2 1: SSH2_MSG_NEWKEYS received Apr 19 10:18:01 EDT: SSH2 1: ssh_receive: 52 bytes received Apr 19 10:18:01 EDT: SSH2 1: input: packet len 32 Apr 19 10:18:01 EDT: SSH2 1: partial packet 8, need 24, maclen 20 Apr 19 10:18:01 EDT: SSH2 1: MAC #3 ok Apr 19 10:18:01 EDT: SSH2 1: input: padlen 10 Apr 19 10:18:01 EDT: SSH2 1: received packet type 5 Apr 19 10:18:01 EDT: SSH2 1: send: len 32 (includes padlen 10) Apr 19 10:18:01 EDT: SSH2 1: done calc MAC out #3 Apr 19 10:18:01 EDT: SSH2 1: ssh_receive: 76 bytes received Apr 19 10:18:01 EDT: SSH2 1: input: packet len 56 Apr 19 10:18:01 EDT: SSH2 1: partial packet 8, need 48, maclen 20 Apr 19 10:18:01 EDT: SSH2 1: MAC #4 ok Apr 19 10:18:01 EDT: SSH2 1: input: padlen 9 Apr 19 10:18:01 EDT: SSH2 1: received packet type 50 Apr 19 10:18:01 EDT: SSH2 1: send: len 24 (includes padlen 5) Apr 19 10:18:01 EDT: SSH2 1: done calc MAC out #4 Apr 19 10:18:01 EDT: SSH2 1: ssh_receive: 92 bytes received Apr 19 10:18:01 EDT: SSH2 1: input: packet len 72 Apr 19 10:18:01 EDT: SSH2 1: partial packet 8, need 64, maclen 20 Apr 19 10:18:01 EDT: SSH2 1: MAC #5 ok Apr 19 10:18:01 EDT: SSH2 1: input: padlen 8 Apr 19 10:18:01 EDT: SSH2 1: received packet type 50 Apr 19 10:18:06 EDT: SSH2 1: send: len 16 (includes padlen 10) Apr 19 10:18:06 EDT: SSH2 1: done calc MAC out #5 Apr 19 10:18:06 EDT: SSH2 1: authentication successful for networkteam Apr 19 10:18:06 EDT: SSH2 1: ssh_receive: 60 bytes received Apr 19 10:18:06 EDT: SSH2 1: input: packet len 40 Apr 19 10:18:06 EDT: SSH2 1: partial packet 8, need 32, maclen 20 Apr 19 10:18:06 EDT: SSH2 1: MAC #6 ok Apr 19 10:18:06 EDT: SSH2 1: input: padlen 11 Apr 19 10:18:06 EDT: SSH2 1: received packet type 90 Apr 19 10:18:06 EDT: SSH2 1: channel open request Apr 19 10:18:06 EDT: SSH2 1: send: len 32 (includes padlen 10) Apr 19 10:18:06 EDT: SSH2 1: done calc MAC out #6 Apr 19 10:18:06 EDT: SSH2 1: ssh_receive: 44 bytes received Apr 19 10:18:06 EDT: SSH2 1: input: packet len 24 Apr 19 10:18:06 EDT: SSH2 1: partial packet 8, need 16, maclen 20 Apr 19 10:18:06 EDT: SSH2 1: MAC #7 ok Apr 19 10:18:06 EDT: SSH2 1: input: padlen 4 Apr 19 10:18:06 EDT: SSH2 1: received packet type 98 Apr 19 10:18:06 EDT: SSH2 1: shell request Apr 19 10:18:06 EDT: SSH2 1: shell message received Apr 19 10:18:06 EDT: SSH2 1: starting shell for vty Apr 19 10:18:06 EDT: SSH2 1: send: len 144 (includes padlen 10) Apr 19 10:18:06 EDT: SSH2 1: done calc MAC out #7 Apr 19 10:18:06 EDT: SSH2 1: send: len 40 (includes padlen 9) Apr 19 10:18:06 EDT: SSH2 1: done calc MAC out #8 Apr 19 10:18:06 EDT: SSH2 1: ssh_receive: 60 bytes received Apr 19 10:18:06 EDT: SSH2 1: input: packet len 40 Apr 19 10:18:06 EDT: SSH2 1: partial packet 8, need 32, maclen 20 Apr 19 10:18:06 EDT: SSH2 1: MAC #8 ok Apr 19 10:18:06 EDT: SSH2 1: input: padlen 11 Apr 19 10:18:06 EDT: SSH2 1: received packet type 90 Apr 19 10:18:06 EDT: SSH2 1: send: len 32 (includes padlen 10) Apr 19 10:18:06 EDT: SSH2 1: done calc MAC out #9 Apr 19 10:18:06 EDT: SSH1: Session disconnected - error 0x07 -- Michael Carpenter <mac...@gm...> |
From: Bryan B. <br...@bu...> - 2006-04-14 18:24:14
|
>> I'm running into a situation here where I need to connect to remote >> servers using this module and be able to execute kron shell file >> commands >> i.e. .ksh. The idea here is to be able to do it while these ksh files >> are >> residing locally where the perl code is run and not on the remote >> servers. >> This is to centralized the code all in one location. >> - Can this be done? >> - If not, can any one suggest workarounds or other solutions? >> - How do admins manage the code that needs to run on 100's of remote >> servers ? >> > > >>Its pretty simple, load the entire shell file into a scalar variable, and >>run that as a command over the channel. If you use return codes to check >>the result its even more trivial as Net::SSH2 and/or Net::SSH::Perl gives >>you the return code of the channel. > >>Hope that helps. > > >>Bryan >>http://sourceforge.net/projects/rover > > I think loading entire script in single variable is not a good idea. Its > difficult for debugging. You will not know where is it going wrong. > > -Gurunath > > I'm not sure I agree with that. You know where you go wrong because you have standard out and standard error streams to read from your Net::SSH object. You would trouble shoot it the same way if you ran the script from the box. When dealing with channels this isnt much different then loading the file to the box, running it, and reading your return code/stdout info. Except you dont have to load the file to the box, which is what your trying to do anyway. Good luck. Bryan http://sourceforge.net/projects/rover |
From: Sander P. <San...@da...> - 2006-04-14 16:48:11
|
=20 How remote is remote? You could use a simple file share (nfs) to make the scripts available to all your servers. Otherwise you could scp the scripts into place before executing them. On the other hand when things get to convoluted it may be a good indication that the strategy is flawed. Expecting ksh scripts to run remotely is a bit far fetched. It may be time to convert the ksh scripts into proper Perl scripts that run centraly and execute their commands remotely via ssh.=20 =20 Let us know some of the restrictions/motivations that are in place so we can help you more, =20 Sander ________________________________ From: ssh...@li... [mailto:ssh...@li...] On Behalf Of CNewtonne Sent: Friday, April 14, 2006 6:08 AM To: ssh-sftp-perl-users Subject: [Ssh-sftp-perl-users] Executing Command FIles (KSH) not Simply One-line Commands I'm running into a situation here where I need to connect to remote servers using this module and be able to execute kron shell file commands i.e. .ksh. The idea here is to be able to do it while these ksh files are residing locally where the perl code is run and not on the remote servers. This is to centralized the code all in one location.=20 - Can this be done? - If not, can any one suggest workarounds or other solutions? - How do admins manage the code that needs to run on 100's of remote servers ? |
From: Gurunath G. <gur...@ya...> - 2006-04-14 15:07:26
|
> I'm running into a situation here where I need to connect to remote > servers using this module and be able to execute kron shell file commands > i.e. .ksh. The idea here is to be able to do it while these ksh files are > residing locally where the perl code is run and not on the remote servers. > This is to centralized the code all in one location. > - Can this be done? > - If not, can any one suggest workarounds or other solutions? > - How do admins manage the code that needs to run on 100's of remote > servers ? > >Its pretty simple, load the entire shell file into a scalar variable, and >run that as a command over the channel. If you use return codes to check >the result its even more trivial as Net::SSH2 and/or Net::SSH::Perl gives >you the return code of the channel. >Hope that helps. >Bryan >http://sourceforge.net/projects/rover I think loading entire script in single variable is not a good idea. Its difficult for debugging. You will not know where is it going wrong. -Gurunath --------------------------------- Love cheap thrills? Enjoy PC-to-Phone calls to 30+ countries for just 2¢/min with Yahoo! Messenger with Voice. |
From: Bryan B. <br...@bu...> - 2006-04-14 13:37:52
|
> I'm running into a situation here where I need to connect to remote > servers using this module and be able to execute kron shell file commands > i.e. .ksh. The idea here is to be able to do it while these ksh files are > residing locally where the perl code is run and not on the remote servers. > This is to centralized the code all in one location. > - Can this be done? > - If not, can any one suggest workarounds or other solutions? > - How do admins manage the code that needs to run on 100's of remote > servers ? > Its pretty simple, load the entire shell file into a scalar variable, and run that as a command over the channel. If you use return codes to check the result its even more trivial as Net::SSH2 and/or Net::SSH::Perl gives you the return code of the channel. Hope that helps. Bryan http://sourceforge.net/projects/rover |
From: CNewtonne <cne...@ya...> - 2006-04-14 13:08:34
|
I'm running into a situation here where I need to connect to remote servers using this module and be able to execute kron shell file commands i.e. .ksh. The idea here is to be able to do it while these ksh files are residing locally where the perl code is run and not on the remote servers. This is to centralized the code all in one location. - Can this be done? - If not, can any one suggest workarounds or other solutions? - How do admins manage the code that needs to run on 100's of remote servers ? |
From: Matt F. <Mat...@no...> - 2006-04-11 20:16:39
|
I'm also having problems with a persistent process using Net::SSH2,= =20 where after it has run for a long period (> 1 day) my scp_put and= =20 channel->exec doesn't work any longer. I start getting lots of LIBSS= H2=20 errors that don't make sense (e.g. Can't open public key file when th= e=20 file is definitely available). Perhaps what Stephen documented is my= =20 problem also? Any ideas on this? Matt Stephen Clouse wrote: > I am using Net::SSH2 as part of a persistent daemon. My issue is t= hat > ::Channel objects (including those that are implicitly created by > scp_get) are not getting destroyed, even though they are leaving > scope. This prevents the main Net::SSH2 object from getting destro= yed > when it goes out of scope, which causes both a memory leak and a > socket descriptor leak. After a few hours of running, our process = fd > space looks like this: > > total 284 > lrwx------ 1 64 Apr 7 13:43 0 -> /dev/pts/2 > lrwx------ 1 64 Apr 7 13:43 1 -> /dev/pts/2 > lrwx------ 1 64 Apr 7 13:43 10 -> socket:[23023727] > lrwx------ 1 64 Apr 7 13:43 100 -> socket:[25941479] > lrwx------ 1 64 Apr 7 13:43 101 -> socket:[25942954] > lrwx------ 1 64 Apr 7 13:43 102 -> socket:[25943607] > lrwx------ 1 64 Apr 7 13:43 103 -> socket:[25945043] > lrwx------ 1 64 Apr 7 13:43 104 -> socket:[25945575] > lrwx------ 1 64 Apr 7 13:43 105 -> socket:[25946014] > lrwx------ 1 64 Apr 7 13:43 106 -> socket:[25947262] > lrwx------ 1 64 Apr 7 13:43 107 -> socket:[25947851] > lrwx------ 1 64 Apr 7 13:43 108 -> socket:[25949223] > lrwx------ 1 64 Apr 7 13:43 109 -> socket:[25950742] > lrwx------ 1 64 Apr 7 13:43 11 -> socket:[23024789] > lrwx------ 1 64 Apr 7 13:43 110 -> socket:[25951710] > lrwx------ 1 64 Apr 7 13:43 111 -> socket:[25952922] > lrwx------ 1 64 Apr 7 13:43 112 -> socket:[25953707] > lrwx------ 1 64 Apr 7 13:43 113 -> socket:[25955436] > lrwx------ 1 64 Apr 7 13:43 114 -> socket:[25957008] > lrwx------ 1 64 Apr 7 13:43 115 -> socket:[25957766] > lrwx------ 1 64 Apr 7 13:43 116 -> socket:[25958984] > lrwx------ 1 64 Apr 7 13:43 117 -> socket:[25993099] > > ...and so on. Eventually the process either consumes all memory or > hits the system fd limit and aborts. > > Here is some debug output from two different sessions. The first o= ne > is looking for files to copy (using SFTP stat) but doesn't find any= .=20 > At the end the Net::SSH2 object is destroyed. > > [debug] start ssh session > libssh2_sftp_init(ss->session) -> 0xa7cc6c0 > hv_from_attrs: attrs->flags =3D 15 > hv_from_attrs: attrs->flags =3D 15 > libssh2_sftp_open_ex(sf->sftp, (char*)pv_file, len_file, l_flags, > mode, 0) -> 0x0 > libssh2_sftp_open_ex(sf->sftp, (char*)pv_file, len_file, l_flags, > mode, 0) -> 0x0 > libssh2_sftp_open_ex(sf->sftp, (char*)pv_file, len_file, l_flags, > mode, 0) -> 0x0 > libssh2_sftp_open_ex(sf->sftp, (char*)pv_file, len_file, l_flags, > mode, 0) -> 0x0 > Net::SSH2::SFTP::DESTROY > Net::SSH2::SFTP::DESTROY freeing session > Net::SSH2::DESTROY > [debug] end ssh session > > The second session does find files it needs to pull down, and calls > scp_get to copy them. Notice the destructor is NOT getting called = at > the end. > > [debug] start ssh session > libssh2_sftp_init(ss->session) -> 0xab1d610 > libssh2_sftp_open_ex(sf->sftp, (char*)pv_file, len_file, l_flags, > mode, 0) -> 0xa7cdc88 > libssh2_scp_recv(ss->session, path, &st) -> 0xcc0aa88 > Net::SSH2::Channel::read(size =3D 1736739, ext =3D 0) > - read 1736739 total > Net::SSH2::Channel::read(size =3D 1, ext =3D 0) > - read 1 bytes > - read 1 total > libssh2_sftp_open_ex(sf->sftp, (char*)pv_file, len_file, l_flags, > mode, 0) -> 0xc403f38 > libssh2_scp_recv(ss->session, path, &st) -> 0xb50bae8 > Net::SSH2::Channel::read(size =3D 826046, ext =3D 0) > - read 826046 total > Net::SSH2::Channel::read(size =3D 1, ext =3D 0) > - read 1 bytes > - read 1 total > libssh2_sftp_open_ex(sf->sftp, (char*)pv_file, len_file, l_flags, > mode, 0) -> 0xa7d2b60 > libssh2_scp_recv(ss->session, path, &st) -> 0xafb63c8 > Net::SSH2::Channel::read(size =3D 28231, ext =3D 0) > - read 28231 total > Net::SSH2::Channel::read(size =3D 1, ext =3D 0) > - read 1 bytes > - read 1 total > [debug] end ssh session > > We have another process similar to this one that opens a shell > channel, which suffers from the same problem. Even when the channe= l > object goes out of scope in our program, its destructor is not call= ed, > and so the Net::SSH2 object is not destroyed either. > > Any help is appreciated. > > -- > Stephen Clouse <ste...@gm...> > N=18=EF=BF=BDHS^=EF=BF=BD=E9=9A=8AX=EF=BF=BD=EF=BF=BD=EF=BF=BD'= =EF=BF=BD=EF=BF=BD=EF=BF=BDu=EF=BF=BD=EF=BF=BD<=EF=BF=BD=DA=82=EF= =BF=BD.=EF=BF=BD=EF=BF=BD=EF=BF=BDy=EF=BF=BD"=EF=BF=BD=0B=1C=EF=BF= =BD*m=EF=BF=BDx%jx.j=07=EF=BF=BD=EF=BF=BD=EF=BF=BD^=EF=BF=BD=D7=A7v= =C6=A9=EF=BF=BDX=EF=BF=BDj=D8=A8=EF=BF=BD=C8=A7=EF=BF=BD=EF=BF=BD= =1Em=EF=BF=BD=DD=9A=EF=BF=BD=EF=BF=BD=EF=BF=BDv&=EF=BF=BD=EF=BF=BD= =D7=A7v=EF=BF=BD^=EF=BF=BD+=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BDj=EF= =BF=BDZ=EF=BF=BD=EF=BF=BD=EF=BF=BD{az=EF=BF=BD=EF=BF=BD=EF=BF=BD^= =EF=BF=BD=EF=BF=BDh=EF=BF=BD=EF=BF=BD=E0=AE=8B=EF=BF=BDn=EF=BF=BD= =EF=BF=BD=EF=BF=BD)=EF=BF=BD{h=EF=BF=BD=18=EF=BF=BD=EF=BF=BD=EF=BF= =BD=1C=EF=BF=BD=D8=A7=EF=BF=BD=D7=AB=EF=BF=BD+h=EF=BF=BD(m=EF=BF=BD= =EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BDZ=EF=BF=BD=EF=BF=BD=1FjY=1A=EF= =BF=BDw=EF=BF=BD=EF=BF=BD=C7=A5rg=EF=BF=BDy$=EF=BF=BD=EF=BF=BD=EF= =BF=BDOx=E1=B8=9D=03n=EF=BF=BDm=1Dj=EF=BF=BD=EF=BF=BD^=EF=BF=BD=EF= =BF=BD+!=EF=BF=BD=EF=BF=BDi=EF=BF=BD=EF=BF=BD=EF=BF=BD=C7=AB=EF=BF= =BDf=EF=BF=BD=EF=BF=BD)=EF=BF=BD+-J=EF=BF=BDl~=EF=BF=BDiz=EF=BF=BDn= =EF=BF=BD=EF=BF=BD=EF=BF=BD+-=EF=BF=BD=EF=BF=BD.=EF=BF=BD=C7=9F=EF= =BF=BD=EF=BF=BD=1E=EF=BF=BD=EF=BF=BDa=EF=BF=BD=EF=BF=BDl=EF=BF=BD= =EF=BF=BDb=EF=BF=BD=EF=BF=BD,=EF=BF=BD=EF=BF=BD=EF=BF=BDy=EF=BF=BD+= =EF=BF=BD=EF=BF=BD=DE=B7=EF=BF=BDb=EF=BF=BD=EF=BF=BD?=EF=BF=BD+-=EF= =BF=BDw=EF=BF=BD=EF=BF=BD=EF=BF=BD!=EF=BF=BD=EF=BF=BDi=EF=BF=BD=EF= =BF=BD=EF=BF=BD=C7=ABs=3D=3D=3D --=20 "A foolish consistency is the hobgoblin of little minds, adored by little statesmen and philosophers and divines." -- Ralph Waldo Emerson |
From: Enrique de A. S. <enr...@pc...> - 2006-04-10 15:52:01
|
Yes, I call several times to cmd method (I use ssh-2 to avoid authenticate against server each time I call this method). I have been investigating more about what can be the problem... having in mind the example code that I sent previously, if I execute it and I connect manually to the remote server, I see that 'myfile' has been created correctly, but if I do a ps, I see that cat command still running. It is like no EOF has been sent! Any idea? Thanks, Enrique. Matthew J. Salerno wrote: > Is it a series of commands you are executing? > > --- Enrique de Andres Saiz > <enr...@pc...> wrote: > > >>Hi everybody, >> >>I have a litle problem when using Net::SSH::Perl. I >>try to execute a >>remote command which requires stdin. When stdin is >>bigger than 32k, cmd >>method hangs up. I'm using ssh-2 protocol, but when >>I use ssh-1 it goes >>well, both with stdin sizes smaller than 32k and >>bigger then 32k. >> >>The code I'm running is the following: >> >>my $ssh; >>eval { >> $ssh = Net::SSH::Perl->new( >> $host, >> protocol => 2, >> compression => 1, >> interactive => 0, >> debug => 1, >> ); >>}; >>die "Cannot connect to host.\n" if ($@); >>eval { >> $ssh->login($user, $pass); >>}; >>die "Cannot authenticate against host.\n" if ($@); >> >>my $stdin = "something"; >>my ($stdout, $stderr, $exit) = $channel->cmd("cat - >> >>>myfile", $stdin); >> >>Could someone help me to make it work with stdin >>bigger than 32k? >> >>Thanks in advance, >> >>Enrique. >> >> >> > > ------------------------------------------------------- > >>This SF.Net email is sponsored by xPML, a >>groundbreaking scripting language >>that extends applications into web and mobile media. >>Attend the live webcast >>and join the prime developer group breaking into >>this new coding territory! >> > > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 > >>_______________________________________________ >>Ssh-sftp-perl-users mailing list >>Ssh...@li... >> > > https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users > > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > > > |
From: Matthew J. S. <vag...@ya...> - 2006-04-10 15:37:41
|
Is it a series of commands you are executing? --- Enrique de Andres Saiz <enr...@pc...> wrote: > Hi everybody, > > I have a litle problem when using Net::SSH::Perl. I > try to execute a > remote command which requires stdin. When stdin is > bigger than 32k, cmd > method hangs up. I'm using ssh-2 protocol, but when > I use ssh-1 it goes > well, both with stdin sizes smaller than 32k and > bigger then 32k. > > The code I'm running is the following: > > my $ssh; > eval { > $ssh = Net::SSH::Perl->new( > $host, > protocol => 2, > compression => 1, > interactive => 0, > debug => 1, > ); > }; > die "Cannot connect to host.\n" if ($@); > eval { > $ssh->login($user, $pass); > }; > die "Cannot authenticate against host.\n" if ($@); > > my $stdin = "something"; > my ($stdout, $stderr, $exit) = $channel->cmd("cat - > > myfile", $stdin); > > Could someone help me to make it work with stdin > bigger than 32k? > > Thanks in advance, > > Enrique. > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a > groundbreaking scripting language > that extends applications into web and mobile media. > Attend the live webcast > and join the prime developer group breaking into > this new coding territory! > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 > _______________________________________________ > Ssh-sftp-perl-users mailing list > Ssh...@li... > https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Enrique de A. S. <enr...@pc...> - 2006-04-10 13:04:57
|
Hi everybody, I have a litle problem when using Net::SSH::Perl. I try to execute a remote command which requires stdin. When stdin is bigger than 32k, cmd method hangs up. I'm using ssh-2 protocol, but when I use ssh-1 it goes well, both with stdin sizes smaller than 32k and bigger then 32k. The code I'm running is the following: my $ssh; eval { $ssh = Net::SSH::Perl->new( $host, protocol => 2, compression => 1, interactive => 0, debug => 1, ); }; die "Cannot connect to host.\n" if ($@); eval { $ssh->login($user, $pass); }; die "Cannot authenticate against host.\n" if ($@); my $stdin = "something"; my ($stdout, $stderr, $exit) = $channel->cmd("cat - > myfile", $stdin); Could someone help me to make it work with stdin bigger than 32k? Thanks in advance, Enrique. |
From: Stephen C. <ste...@gm...> - 2006-04-07 21:22:31
|
SSBhbSB1c2luZyBOZXQ6OlNTSDIgYXMgcGFydCBvZiBhIHBlcnNpc3RlbnQgZGFlbW9uLiAgTXkg aX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hZCA4MjYwNDYgdG90YWwKTmV0OjpTU0gyOjpDaGFubmVsOjpyZWFkKHNpemUgPSAx LCBleHQgPSAwKQotIHJlYWQgMSBieXRlcwotIHJlYWQgMSB0b3RhbApsaWJzc2gyX3NmdHBfb3Bl bl9leChzZi0+c2Z0cCwgKGNoYXIqKXB2X2ZpbGUsIGxlbl9maWxlLCBsX2ZsYWdzLAptb2RlLCAw KSAtPiAweGE3ZDJiNjAKbGlic3NoMl9zY3BfcmVjdihzcy0+c2Vzc2lvbiwgcGF0aCwgJnN0KSAt PiAweGFmYjYzYzgKTmV0OjpTU0gyOjpDaGFubmVsOjpyZWFkKHNpemUgPSAyODIzMSwgZXh0ID0g MCkKLSByZWFkIDI4MjMxIHRvdGFsCk5ldDo6U1NIMjo6Q2hhbm5lbDo6cmVhZChzaXplID0gMSwg ZXh0ID0gMCkKLSByZWFkIDEgYnl0ZXMKLSByZWFkIDEgdG90YWwKW2RlYnVnXSBlbmQgc3NoIHNl c3Npb24KCldlIGhhdmUgYW5vdGhlciBwcm9jZXNzIHNpbWlsYXIgdG8gdGhpcyBvbmUgdGhhdCBv cGVucyBhIHNoZWxsCmNoYW5uZWwsIHdoaWNoIHN1ZmZlcnMgZnJvbSB0aGUgc2FtZSBwcm9ibGVt LiAgRXZlbiB3aGVuIHRoZSBjaGFubmVsCm9iamVjdCBnb2VzIG91dCBvZiBzY29wZSBpbiBvdXIg cHJvZ3JhbSwgaXRzIGRlc3RydWN0b3IgaXMgbm90IGNhbGxlZCwKYW5kIHNvIHRoZSBOZXQ6OlNT SDIgb2JqZWN0IGlzIG5vdCBkZXN0cm95ZWQgZWl0aGVyLgoKQW55IGhlbHAgaXMgYXBwcmVjaWF0 ZWQuCgotLQpTdGVwaGVuIENsb3VzZSA8c3RlcGhlbmNsb3VzZUBnbWFpbC5jb20+Cg== |
From: Matthew J. S. <vag...@ya...> - 2006-04-06 19:22:21
|
After messing with this module for the last few weeks, I don't bother with the documentation, I look at the source first. Good luck --- Steve Kirkup <he...@ya...> wrote: > Mathew, > > The 'DSSAuthentication' parameter did the trick!, > Well that and the Crypt::DSA module... > > Those options would have been more help though if > the > yare actually included in the documentation. Some > of > those I recognize but there are quite a few options > in > there that are not documented. > > Steve Kirkup > > --- "Matthew J. Salerno" <vag...@ya...> > wrote: > > > You might need to specify some options for the > > connection, especially, DSAAuthentication. > > > > $params{"DSAAuthentication"} = "yes"; > > > > my $ssh = Net::SSH::Perl->new($host, %params); > > > > Here is a full list of params you can pass: > > > http://search.cpan.org/~dbrobins/Net-SSH-Perl-1.30/lib/Net/SSH/Perl/Config.pm > > > > BindAddress > > Host > > BatchMode > > ChallengeResponseAuthentication > > Cipher > > Ciphers > > Compression > > CompressionLevel > > DSAAuthentication > > GlobalKnownHostsFile > > HostKeyAlgorithms > > HostName > > IdentityFile > > NumberOfPasswordPrompts > > PasswordAuthentication > > PasswordPromptHost > > PasswordPromptLogin > > Port > > Protocol > > RhostsAuthentication > > RhostsRSAAuthentication > > RSAAuthentication > > UsePrivilegedPort > > User > > UserKnownHostsFile > > > > > > > > > > --- Steve Kirkup <he...@ya...> wrote: > > > > > howdy, > > > > > > I was trying to setup Net::SSH::Perl to work > with > > an > > > id_dsa key file. I do not want to store a > password > > > in > > > my code or config file. I got ssh and scp to > work > > > with using the id_dsa key file with my remote > host > > > (ie > > > it does not prompt me for a password). However, > I > > > cannot get my scripting to work without using a > > > password? Can someone point me in the right > > > direction? > > > > > > --script starts here-- > > > > > > use Net::SSH::Perl; > > > > > > my $server = Net::SSH::Perl->new( > > > 'www.my.server.gov', > > > identity_files => [$ENV{HOME}. > > "/.ssh/id_dsa"], > > > ); > > > > > > $server->login('myuser') or die "Cannot log > > in\n";; > > > > > > warn "Logged in\n"; > > > > > > --script ends here-- > > > > > > Steve Kirkup > > > > > > > > > > __________________________________________________ > > > Do You Yahoo!? > > > Tired of spam? Yahoo! Mail has the best spam > > > protection around > > > http://mail.yahoo.com > > > > > > > > > > > > ------------------------------------------------------- > > > This SF.Net email is sponsored by xPML, a > > > groundbreaking scripting language > > > that extends applications into web and mobile > > media. > > > Attend the live webcast > > > and join the prime developer group breaking into > > > this new coding territory! > > > > > > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 > > > _______________________________________________ > > > Ssh-sftp-perl-users mailing list > > > Ssh...@li... > > > > > > https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users > > > > > > > > > __________________________________________________ > > Do You Yahoo!? > > Tired of spam? Yahoo! Mail has the best spam > > protection around > > http://mail.yahoo.com > > > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam > protection around > http://mail.yahoo.com > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Matthew J. S. <vag...@ya...> - 2006-04-06 15:31:03
|
You might need to specify some options for the connection, especially, DSAAuthentication. $params{"DSAAuthentication"} = "yes"; my $ssh = Net::SSH::Perl->new($host, %params); Here is a full list of params you can pass: http://search.cpan.org/~dbrobins/Net-SSH-Perl-1.30/lib/Net/SSH/Perl/Config.pm BindAddress Host BatchMode ChallengeResponseAuthentication Cipher Ciphers Compression CompressionLevel DSAAuthentication GlobalKnownHostsFile HostKeyAlgorithms HostName IdentityFile NumberOfPasswordPrompts PasswordAuthentication PasswordPromptHost PasswordPromptLogin Port Protocol RhostsAuthentication RhostsRSAAuthentication RSAAuthentication UsePrivilegedPort User UserKnownHostsFile --- Steve Kirkup <he...@ya...> wrote: > howdy, > > I was trying to setup Net::SSH::Perl to work with an > id_dsa key file. I do not want to store a password > in > my code or config file. I got ssh and scp to work > with using the id_dsa key file with my remote host > (ie > it does not prompt me for a password). However, I > cannot get my scripting to work without using a > password? Can someone point me in the right > direction? > > --script starts here-- > > use Net::SSH::Perl; > > my $server = Net::SSH::Perl->new( > 'www.my.server.gov', > identity_files => [$ENV{HOME}. "/.ssh/id_dsa"], > ); > > $server->login('myuser') or die "Cannot log in\n";; > > warn "Logged in\n"; > > --script ends here-- > > Steve Kirkup > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam > protection around > http://mail.yahoo.com > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a > groundbreaking scripting language > that extends applications into web and mobile media. > Attend the live webcast > and join the prime developer group breaking into > this new coding territory! > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 > _______________________________________________ > Ssh-sftp-perl-users mailing list > Ssh...@li... > https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Steve K. <he...@ya...> - 2006-04-06 14:23:55
|
howdy, I was trying to setup Net::SSH::Perl to work with an id_dsa key file. I do not want to store a password in my code or config file. I got ssh and scp to work with using the id_dsa key file with my remote host (ie it does not prompt me for a password). However, I cannot get my scripting to work without using a password? Can someone point me in the right direction? --script starts here-- use Net::SSH::Perl; my $server = Net::SSH::Perl->new( 'www.my.server.gov', identity_files => [$ENV{HOME}. "/.ssh/id_dsa"], ); $server->login('myuser') or die "Cannot log in\n";; warn "Logged in\n"; --script ends here-- Steve Kirkup __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Matthew J. S. <vag...@ya...> - 2006-04-03 16:25:24
|
I am currently using the module I got from www.soulcage.net, but it's old (1.23). I am just wondering if anyone has gotten it to work with the latest version on windows? Thanks, Matt __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Matthew J. S. <vag...@ya...> - 2006-03-31 17:09:56
|
After banging my head against the wall for the last week and a half, I finally got something working. I used the code from the shell sub in Net::SSH::Perl::SSH2. Basically I copied the shell sub into my main script and changed 2 lines. I send all of the data that is received during an ssh session to a sub named: ssh_interact In ssh_interact, the received data is compared to what we are expecting to receive, and when a match is made, the specified command is sent. The logic in the sub completely depends on what you plan on doing with it. I gave an example below, but it's wide open, so do what you want. Now that I have done this, I will kick myself for the rest of the week for not thinking about it earlier. This also works with Net::SSH::W32Perl #!/usr/bin/perl -w use strict; use Net::SSH::Perl; use Net::SSH::Perl::Constants qw( :msg2 ); my %params; $params{"debug"} = 0; $params{"port"} = 22; $params{"protocol"} = 2; $params{"interactive"} = 1; $params{"compression"} = 0; $params{"PreferredAuthentications"} = 'password'; $params{"PubkeyAuthentication"} = 'no'; $params{"RSAAuthentication"} = 'no'; $params{"password_prompt_host"} = 0; $params{"auth_kbd_interactive"} = 0; $params{"use_pty"} = 0; my $stdoutcnt = 0; my $host = "10.10.10.127"; my $user = "username"; my $pw = "password"; my $ssh = Net::SSH::Perl->new($host, %params, options => ["BatchMode no"]) || die "Cannot Connect to system $! $@\n"; print "Opening Connection\n"; $ssh->login($user,$pw) || die "Cannot Login $! $@\n"; my $cmgr = $ssh->channel_mgr; my $channel = $ssh->_session_channel; $channel->open; $channel->register_handler(SSH2_MSG_CHANNEL_OPEN_CONFIRMATION, sub { my($channel, $packet) = @_; my $r_packet = $channel->request_start('pty-req', 0); my($term) = $ENV{TERM} =~ /(\w+)/; $r_packet->put_str($term); $r_packet->put_int32(0) for 1..4; $r_packet->put_str(""); $r_packet->send; $channel->{ssh}->debug("Requesting shell."); $channel->request("shell", 0); }); my($exit); $channel->register_handler(SSH2_MSG_CHANNEL_REQUEST, $ssh->_make_input_channel_req(\$exit)); $channel->register_handler("_output_buffer", sub { syswrite STDOUT, $_[1]->bytes; ssh_interact($_[1]->bytes); }); $channel->register_handler("_extended_buffer", sub { syswrite STDERR, $_[1]->bytes; }); $ssh->debug("Entering interactive session."); $ssh->client_loop; sub ssh_interact { # Here is where the interaction happens # All prompts get printed to the screen # as well as put in $stdout # # From this sub, you can execute commands # and interact with them as well. # # You just need to know what the prompts # will be and then you can script them. # # There is alot of logic that can be added # here, but that's up to each user. # # You can keep track of where you are by # following $stdoutcnt. This entire sub # could be written much better, but it's just # an example. $expected1 = "[user@machine ~]#"; $expected2 = qq|cp: overwrite `/var/log/messages'?|; # Notice that at the end of the commands I am # sending a \n $command1 = "cp /etc/fstab /var/log/messages\n"; $command2 = "n\n"; print "STDOUTcnd - $stdoutcnt\n"; my $stdout = $_[0]; if ($stdout =~ /$expected1/i){ $channel->send_data($command1); $stdoutcnt++; return; } if ($stdout =~ /$expected2/i){ $channel->send_data("$command2"); $stdoutcnt++; return; } } __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Matthew J. S. <vag...@ya...> - 2006-03-31 14:12:23
|
I have been going through the Net::SSH::Perl::SSH2 modules looking for a way to mimic/hack the shell sub so that rather than taking keyboard input, I can script it. I can find the stdout from the ssh server, and I even found a part where the entered data is sent, but I am still having problems. I am wondering if anyone else has been able to get this approach to actually work with interactive commands, and if so would you mind sharing. Thanks __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Bobby J. <bob...@se...> - 2006-03-30 23:33:35
|
>You may need to add an entry in your services file... >%System Dir%\{WINDOWS|WINNT}\system32\drivers\etc >ssh 22/tcp #SSH. control I have added the above to my services file. I can now go one step further than before. But I get a new error: Can't locate Math/GMP.pm in @INC (@INC contains: s:\ctam\qa-tests\lib C:/Perl/li b C:/Perl/site/lib .) at C:/Perl/site/lib/Net/SSH/Perl/Util/SSH1MP.pm line 7, <G EN0> line 1. BEGIN failed--compilation aborted at C:/Perl/site/lib/Net/SSH/Perl/Util/SSH1MP.p m line 7, <GEN0> line 1. Compilation failed in require at C:/Perl/site/lib/Net/SSH/Perl/Util.pm line 56, <GEN0> line 1. BEGIN failed--compilation aborted at C:/Perl/site/lib/Net/SSH/Perl/Key/RSA1.pm l ine 6, <GEN0> line 1. Compilation failed in require at C:/Perl/site/lib/Net/SSH/Perl/SSH1.pm line 13, <GEN0> line 1. BEGIN failed--compilation aborted at C:/Perl/site/lib/Net/SSH/Perl/SSH1.pm line 13, <GEN0> line 1. Compilation failed in require at C:/Perl/site/lib/Net/SSH/Perl.pm line 55, <GEN0 > line 1. There were 2 Failures in Test Case memtest.pl I am unable to install Math::GMP using PPM (install Math-GMP). I get the error: Error: Failed to download URL http://www.soulcage.net/ppds.58/Math-GMP.ppd: 404 Not Found >I get the following error, if I run the scripts in Windows: >Can't map service name 'ssh' to port number at memtest.pl line 8. >#!/usr/bin/perl >use strict; >use Net::SSH::w32Perl; >my $user =3D "root"; >my $pass =3D "password"; >my $host =3D "192.168.0.173"; >my $cmd =3D "cat /proc/meminfo | grep MemFree"; my $ssh =3D Net::SSH::Perl->new($host); $ssh->login($user, $pass); for (1..1000) { > my ($stdout, $stderr, $exit) =3D $ssh->cmd($cmd); > my @temp =3D split /\s+/, $stdout; > my $FreeMem =3D $temp[1]; > Print "Current Free memory is: $FreeMem" if ($FreeMem > 10000); > print "Free memory has dropped below 10K:$FreeMem" if ($FreeMem < 10000); > if ($FreeMem < 2000) > { > print "Critical Error. Free Mem is: FreeMem"; > last; > } > sleep 600; >} |
From: Matthew J. S. <vag...@ya...> - 2006-03-30 22:51:33
|
The solution to your problem migh just be as simple as you reviewing your code and doing some reading, but usually it's really really helpfull if you actually post what the error is! Is this module suppose to be equivalent to Net::SSH:Perl READ: http://search.cpan.org/~scotts/Net-SSH-W32Perl-0.05/lib/Net/SSH/W32Perl.pm CPAN is a great resource, use it. Are you sure you want to create the object with: my $ssh = Net::SSH::Perl->new($host); You probably mean: my $ssh = Net::SSH::W32Perl->new($host); --- Bobby Jafari <bob...@se...> wrote: > Hi All, > > >Make sure you use the correct repo. > >Installing on Perl 5.8.x ( It uses old versions, > but it works ) > >ppm3 > >rep add soulcage http://www.soulcage.net/ppds.58/ > install > Net-SSH-W32Perl > >Installing on Perl 5.6.x ( It uses old versions, > but it works ) > >rep add soulcage http://www.soulcage.net/ppds/ > install Net-SSH-W32Perl > > Note that I have successfully installed > Net::SSH:w32Perl. How ever I > have problems running my scripts. Is this module > suppose to be > equivalent to Net::SSH:Perl (A Perl module for > Linux). I have a script > that runs in Linux land without any problems but I > can't get it to run > on WinXP. I need to provide a WinXP box for a third > party to run some > tests and Hence the need for using window (Even > though I personally > can't stand WinXP). My Linux based script is: > > #!/usr/bin/perl > use strict; > use Net::SSH::w32Perl; > use Net::SSH::Perl; > my $user = "root"; > my $pass = "password"; > my $host = "192.168.0.173"; > my $cmd = "cat /proc/meminfo | grep MemFree"; > my $ssh = Net::SSH::Perl->new($host); > $ssh->login($user, $pass); > for (1..1000) > { > my ($stdout, $stderr, $exit) = $ssh->cmd($cmd); > my @temp = split /\s+/, $stdout; > my $FreeMem = $temp[1]; > Print "Current Free memory is: $FreeMem" if > ($FreeMem > 10000); > print "Current Free memory has dropped below > 10K. Free Mem is: > $FreeMem" if ($FreeMem < 10000); > if ($FreeMem < 2000) > { > print "Critical Error. Current Free memory > has dropped below 2K. > Free Mem is: FreeMem"; > last; > } > sleep 600; > } > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a > groundbreaking scripting language > that extends applications into web and mobile media. > Attend the live webcast > and join the prime developer group breaking into > this new coding territory! > http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642 > _______________________________________________ > Ssh-sftp-perl-users mailing list > Ssh...@li... > https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Bobby J. <bob...@se...> - 2006-03-30 22:43:10
|
I get the following error, if I run the scripts in Windows: Can't map service name 'ssh' to port number at memtest.pl line 8. #!/usr/bin/perl use strict; use Net::SSH::w32Perl; my $user =3D "root"; my $pass =3D "password"; my $host =3D "192.168.0.173"; my $cmd =3D "cat /proc/meminfo | grep MemFree";=20 my $ssh =3D Net::SSH::Perl->new($host);=20 $ssh->login($user, $pass); for (1..1000)=20 { my ($stdout, $stderr, $exit) =3D $ssh->cmd($cmd); my @temp =3D split /\s+/, $stdout; my $FreeMem =3D $temp[1]; Print "Current Free memory is: $FreeMem" if ($FreeMem > 10000); print "Free memory has dropped below 10K:$FreeMem" if ($FreeMem < 10000); if ($FreeMem < 2000) { print "Critical Error. Free Mem is: FreeMem"; last; } sleep 600; } |
From: Bobby J. <bob...@se...> - 2006-03-30 22:18:02
|
Hi All, >Make sure you use the correct repo. >Installing on Perl 5.8.x ( It uses old versions, but it works ) >ppm3 >rep add soulcage http://www.soulcage.net/ppds.58/ install Net-SSH-W32Perl >Installing on Perl 5.6.x ( It uses old versions, but it works ) >rep add soulcage http://www.soulcage.net/ppds/ install Net-SSH-W32Perl Note that I have successfully installed Net::SSH:w32Perl. How ever I have problems running my scripts. Is this module suppose to be equivalent to Net::SSH:Perl (A Perl module for Linux). I have a script that runs in Linux land without any problems but I can't get it to run on WinXP. I need to provide a WinXP box for a third party to run some tests and Hence the need for using window (Even though I personally can't stand WinXP). My Linux based script is: #!/usr/bin/perl use strict; use Net::SSH::w32Perl; use Net::SSH::Perl; my $user =3D "root"; my $pass =3D "password"; my $host =3D "192.168.0.173"; my $cmd =3D "cat /proc/meminfo | grep MemFree"; my $ssh =3D Net::SSH::Perl->new($host); $ssh->login($user, $pass); for (1..1000) { my ($stdout, $stderr, $exit) =3D $ssh->cmd($cmd); my @temp =3D split /\s+/, $stdout; my $FreeMem =3D $temp[1]; Print "Current Free memory is: $FreeMem" if ($FreeMem > 10000); print "Current Free memory has dropped below 10K. Free Mem is: $FreeMem" if ($FreeMem < 10000); if ($FreeMem < 2000) { print "Critical Error. Current Free memory has dropped below 2K. Free Mem is: FreeMem"; last; } sleep 600; } |
From: Matthew J. S. <vag...@ya...> - 2006-03-30 14:14:48
|
Make sure you use the correct repo. Installing on Perl 5.8.x ( It uses old versions, but it works ) ppm rep add soulcage http://www.soulcage.net/ppds.58/ install Net-SSH-W32Perl Installing on Perl 5.6.x ( It uses old versions, but it works ) ppm rep add soulcage http://www.soulcage.net/ppds/ install Net-SSH-W32Perl --- Bobby Jafari <bob...@se...> wrote: > Hi All, > > I have tried to install Net::SSH::Perl on windows XP > using PPM3. It does > not find the package. Does that mean I need to > manually build the > package on the PC? > > Regards, > Bobby Jafari > Test Engineer > Senetas Security Pty Ltd > Office: +61 3 9868 4529 > Mobile: +61 404 089 021 > E-Mail: bob...@se... > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Bobby J. <bob...@se...> - 2006-03-30 07:11:17
|
Hi All, I have tried to install Net::SSH::Perl on windows XP using PPM3. It does not find the package. Does that mean I need to manually build the package on the PC? Regards, Bobby Jafari Test Engineer Senetas Security Pty Ltd Office: +61 3 9868 4529 Mobile: +61 404 089 021 E-Mail: bob...@se... |
From: Bobby J. <bob...@se...> - 2006-03-30 05:12:32
|
Hi All, >You need to install the Net::SSH::Perl module. >you can use the cpan shell to install it ># cpan install Net::SSH::Perl >libnet-ssh-perl is probably used by Net::SSH libnet-ssh-perl package of debian was the incorrect package. I had to Manually install Net::SH:Perl using the cpan shell. Regards, Bobby |