FWD: Re: [Ssh-sftp-perl-users] RE: Ssh-sftp-perl-users digest, Vol 1 #59 - 2 msgs
Brought to you by:
dbrobins
From: evegdahl v. <eve...@ve...> - 2004-12-22 18:52:27
|
Glad to see I am not alone... I first decribed the exact same problem back in august.... but no one respo= nded. Connection/channel it does not seem to make any difference, they ar= e running in a different shell. This is not desirable. I was looking for= the same functionality of the Net::tlenet module. But this does not seem = to be it. Here is a sample program I have tried to run: #!/usr/perl5/5.8.5/bin/perl use Net::SSH::Perl; use Net::SSH::Perl::Cipher; # $t =3D Net::SSH::Perl->new("c_9509_b",port =3D> 22, protocal =3D> 2, cip= her =3D> blowfish-cbc, debug =3D> 1); $t =3D Net::SSH::Perl->new("c_9509_b",port =3D> 22, options =3D> ["protocal= 2"], debug =3D> 1); $t->login("user","password"); # ($out,$err,$exit) =3D $t->cmd("config t"); printf(STDOUT "Exit code =3D \"$exit\"\n"); printf(STDOUT "STDOUT =3D \"$out\"\n"); printf(STDOUT "STDERR =3D \"$err\"\n"); ($out,$err,$exit) =3D $t->cmd("fcalias name D280_23_a1 vsan 1"); printf(STDOUT "Exit code =3D \"$exit\"\n"); printf(STDOUT "STDOUT =3D \"$out\"\n"); printf(STDOUT "STDERR =3D \"$err\"\n"); ($out,$err,$exit) =3D $t->cmd("member pwwn 200200a0b80f6bf5"); printf(STDOUT "Exit code =3D \"$exit\"\n"); printf(STDOUT "STDOUT =3D \"$out\"\n"); printf(STDOUT "STDERR =3D \"$err\"\n"); ($out,$err,$exit) =3D $t->cmd("exit"); printf(STDOUT "Exit code =3D \"$exit\"\n"); printf(STDOUT "STDOUT =3D \"$out\"\n"); printf(STDOUT "STDERR =3D \"$err\"\n"); This program produces the output: ~/cur> ed1 sb8: Reading configuration data /home/evegdahl/.ssh/config sb8: Reading configuration data /etc/ssh_config sb8: Connecting to c_9509_b, port 22. sb8: Remote protocol version 2.0, remote software version OpenSSH_3.5p1 sb8: Net::SSH::Perl Version 1.25, protocol version 2.0. sb8: No compat match: OpenSSH_3.5p1. sb8: Connection established. sb8: Sent key-exchange init (KEXINIT), wait response. sb8: Algorithms, c->s: 3des-cbc hmac-sha1 none sb8: Algorithms, s->c: 3des-cbc hmac-sha1 none sb8: Entering Diffie-Hellman Group 1 key exchange. sb8: Sent DH public key, waiting for reply. sb8: Received host key, type 'ssh-dss'. sb8: Host 'c_9509_b' is known and matches the host key. sb8: Computing shared secret key. sb8: Verifying server signature. sb8: Waiting for NEWKEYS message. sb8: Enabling incoming encryption/MAC/compression. sb8: Send NEWKEYS, enable outgoing encryption/MAC/compression. sb8: Sending request for user-authentication service. sb8: Service accepted: ssh-userauth. sb8: Trying empty user-authentication request. sb8: Authentication methods that can continue: publickey,password,keyboard-= interactive. sb8: Next method to try is publickey. sb8: Next method to try is password. sb8: Trying password authentication. sb8: Login completed, opening dummy shell channel. sb8: channel 0: new [client-session] sb8: Requesting channel_open for channel 0. sb8: channel 0: open confirm rwindow 0 rmax 32768 sb8: Got channel open confirmation, requesting shell. sb8: Requesting service shell on channel 0. sb8: channel 1: new [client-session] sb8: Requesting channel_open for channel 1. sb8: Entering interactive session. sb8: Sending command: config t sb8: Requesting service exec on channel 1. sb8: channel 1: open confirm rwindow 0 rmax 32768 sb8: channel 0: rcvd eof sb8: channel 0: output open -> drain sb8: channel 0: rcvd close sb8: channel 0: input open -> closed sb8: channel 0: close_read sb8: input_channel_request: rtype exit-status reply 0 sb8: channel 1: rcvd eof sb8: channel 1: output open -> drain sb8: channel 1: rcvd close sb8: channel 1: input open -> closed sb8: channel 1: close_read sb8: channel 1: obuf empty sb8: channel 1: output drain -> closed sb8: channel 1: close_write sb8: channel 1: send close sb8: channel 1: full closed Exit code =3D "0" STDOUT =3D "" STDERR =3D "" sb8: channel 2: new [client-session] sb8: Requesting channel_open for channel 2. sb8: Entering interactive session. sb8: Sending command: fcalias name D280_23_a1 vsan 1 sb8: Requesting service exec on channel 2. sb8: channel 2: open confirm rwindow 0 rmax 32768 sb8: input_channel_request: rtype exit-status reply 0 sb8: channel 2: rcvd eof sb8: channel 2: output open -> drain sb8: channel 2: rcvd close sb8: channel 2: input open -> closed sb8: channel 2: close_read sb8: channel 2: obuf empty sb8: channel 2: output drain -> closed sb8: channel 2: close_write sb8: channel 2: send close sb8: channel 2: full closed Exit code =3D "11" STDOUT =3D " Cmd parse error. " STDERR =3D "" sb8: channel 3: new [client-session] sb8: Requesting channel_open for channel 3. sb8: Entering interactive session. sb8: Sending command: member pwwn 200200a0b80f6bf5 sb8: Requesting service exec on channel 3. sb8: channel 3: open confirm rwindow 0 rmax 32768 sb8: input_channel_request: rtype exit-status reply 0 sb8: channel 3: rcvd eof sb8: channel 3: output open -> drain sb8: channel 3: rcvd close sb8: channel 3: input open -> closed sb8: channel 3: close_read sb8: channel 3: obuf empty sb8: channel 3: output drain -> closed sb8: channel 3: close_write sb8: channel 3: send close sb8: channel 3: full closed Exit code =3D "11" STDOUT =3D " Cmd parse error. " STDERR =3D "" sb8: channel 4: new [client-session] sb8: Requesting channel_open for channel 4. sb8: Entering interactive session. sb8: Sending command: exit sb8: Requesting service exec on channel 4. sb8: channel 4: open confirm rwindow 0 rmax 32768 sb8: input_channel_request: rtype exit-status reply 0 sb8: channel 4: rcvd eof sb8: channel 4: output open -> drain sb8: channel 4: rcvd close sb8: channel 4: input open -> closed sb8: channel 4: close_read sb8: channel 4: obuf empty sb8: channel 4: output drain -> closed sb8: channel 4: close_write sb8: channel 4: send close sb8: channel 4: full closed Exit code =3D "0" STDOUT =3D "" STDERR =3D "" ~/cur> ---------- Original Message ---------------------------------- From: Mihai Secasiu <mih...@de...> Date: Mon, 13 Dec 2004 12:33:34 +0200 Did you try creating the ssh object like this: Net::SSH::Perl->new($domain,port =3D> $port,options =3D> ["Protocol 2"])) On Monday 13 December 2004 08:00, Andersson, Kimmo wrote: > Hi ! > > The documentation says so and You say so but that does not work. At least= > the results are not what You want. > > I had a similar case. On a HP-UX machine I wanted to import an Oracle > export file which my Perl script had transferred using FTP. To use Import= I > have to setup the environment first (first command) using a shell script.= > However I'm certain that SSH 2 was used but the environment settings were= > lost while issuing the second command (import). > > To maintain the environment setting I had to chain the two commands into > one command. > Using Your example something like this: > ($out,$err,$rc) =3D $ssh->cmd("export FOO=3DWIBBLE";"print $FOO";); > > That should work irrespective of the SSH version. > > BR Kimmo Andersson > Jyv=E4skyl=E4, Finland > > >you can execute multiple commands on the same channel if you use SSH 2 > > > >On Friday 10 December 2004 13:03, Wildish, Joe wrote: > >> I originally thought that I could use Net::SSH::Perl to issue multiple= > >> commands in the same shell. However, having looked into it a little > >> more, it seems that this is not the default behaviour. I have done a > >> little research, and it appears that a seperate channel is created eac= h > >> time the cmd method is called - which effectively creates a new shell.= > >> > >> I am wanting to execute the commands in the same shell. For example: > >> > >> ($out,$err,$rc) =3D $ssh->cmd("export FOO=3DWIBBLE"); > >> ($out2,$err2,$rc2) =3D $ssh->cmd("print $FOO"); > >> > >> $out2 would equal "WIBBLE".... > >> > >> I think I can probably achieve this behaviour by registering a handler= > >> and iterating through each of the commands I want to issue within the > >> subroutine, but this doesn't seem the nicest way. Ideally, if I could > >> pass in the channel number to the cmd method, that would be cool... I = am > >> assuming of course that there are no problems with this approach? > >> > >> I was hoping people on this list may have come across this requirement= > >> before, and could perhaps point me in the right direction .... (?) > >> > >> Regards, > >> Joe > > > >-- > >+-----------------------------------------------------------------------= > > > >| Mihai Secasiu > >| http://denixsolutions.com/ > >| Complete Unix/Linux Solutions for your Business > > > >+-----------------------------------------------------------------------= > > > > > >--__--__-- > > > >Message: 2 > >From: Mihai Secasiu <mih...@de...> > >Organization: Denix Solutions > >To: ssh...@li... > >Subject: Re: [Ssh-sftp-perl-users] Net::SFTP error handling - patch? > >Date: Sun, 12 Dec 2004 20:20:42 +0200 > > > >You can send the patch here, I will review it and merge it into the code= . > > > >On Friday 10 December 2004 23:48, David Robins wrote: > >> I'd like to add some error handling with the result of having > >> Net::SFTP's put method return success (true)/failure (false), and > >> perhaps some other patches too: > >> > >> - similar return for 'get' (unless there's no local file specified, in= > >> which case the file contents are returned) (as reported [not by me] > >> about > > > >a > > > >> year ago at http://rt.cpan.org/NoAuth/Bug.html?id=3D4610) - allow warn= ings > > > >to > > > >> be redirected to a callback (or turned off), defaulting to warn for > >> backwards compatibility > >> > >> If these seem like a good idea I'll write up and submit a patch (if I > >> do, where should I send it to, this list?) > >> > >> Thanks, > > > >-- > >+-----------------------------------------------------------------------= > > > >| Mihai Secasiu > >| http://denixsolutions.com/ > >| Complete Unix/Linux Solutions for your Business > > > >+-----------------------------------------------------------------------= > > > > > > > >--__--__-- > > > >_______________________________________________ > >Ssh-sftp-perl-users mailing list > >Ssh...@li... > >https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users > > > > > >End of Ssh-sftp-perl-users Digest -- +----------------------------------------------------------------------- | Mihai Secasiu | http://denixsolutions.com/ | Complete Unix/Linux Solutions for your Business +----------------------------------------------------------------------- ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/ _______________________________________________ Ssh-sftp-perl-users mailing list Ssh...@li... https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users ________________________________________________________________ Sent via the WebMail system at vegdahl.com |