[Ssh-sftp-perl-users] RE: Ssh-sftp-perl-users digest, Vol 1 #59 - 2 msgs
Brought to you by:
dbrobins
From: Andersson, K. <Kim...@yo...> - 2004-12-13 06:00:56
|
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.=20 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.=20 =20 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 = each >> 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 = warnings >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 |