RE: [Ssh-sftp-perl-users] RE: Ssh-sftp-perl-users digest, Vol 1 #59 - 2 msgs
Brought to you by:
dbrobins
From: Wildish, J. <Joe...@ca...> - 2004-12-13 11:06:04
|
Hi there! =20 I noticed that I can chain commands together in that fashion. However, = I'm trying to write a generic handler for issuing multiple commands on a = box - I want to be able to check return codes, ouptut, etc, before = moving onto the next command; of course, I also want the commands to be = in the same shell.... :-) I have some (nasty) work arounds, but I'm = really hoping I can get this working first. =20 Regards, Joe -----Original Message----- From: ssh...@li... = [mailto:ssh...@li...] On Behalf Of = Andersson, Kimmo Sent: 13 December 2004 06:01 To: 'ssh...@li...' Subject: [Ssh-sftp-perl-users] RE: Ssh-sftp-perl-users digest, Vol 1 = #59 - 2 msgs =09 =09 Hi !=20 The documentation says so and You say so but that does not work. At = least the results are not what You want.=20 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:=20 ($out,$err,$rc) =3D $ssh->cmd("export FOO=3DWIBBLE";"print $FOO";);=20 That should work irrespective of the SSH version.=20 =20 BR Kimmo Andersson=20 Jyv=E4skyl=E4, Finland=20 >you can execute multiple commands on the same channel if you use SSH 2 = >On Friday 10 December 2004 13:03, Wildish, Joe wrote:=20 >> I originally thought that I could use Net::SSH::Perl to issue = multiple=20 >> commands in the same shell. However, having looked into it a little=20 >> 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=20 >> time the cmd method is called - which effectively creates a new = shell.=20 >>=20 >> I am wanting to execute the commands in the same shell. For example: = >>=20 >> ($out,$err,$rc) =3D $ssh->cmd("export FOO=3DWIBBLE");=20 >> ($out2,$err2,$rc2) =3D $ssh->cmd("print $FOO");=20 >>=20 >> $out2 would equal "WIBBLE"....=20 >>=20 >> I think I can probably achieve this behaviour by registering a = handler=20 >> and iterating through each of the commands I want to issue within = the=20 >> subroutine, but this doesn't seem the nicest way. Ideally, if I = could=20 >> pass in the channel number to the cmd method, that would be cool... = I am=20 >> assuming of course that there are no problems with this approach?=20 >>=20 >> I was hoping people on this list may have come across this = requirement=20 >> before, and could perhaps point me in the right direction .... (?)=20 >>=20 >> Regards,=20 >> Joe=20 >=20 >--=20 = >+-----------------------------------------------------------------------= =20 >| Mihai Secasiu=20 >| http://denixsolutions.com/=20 >| Complete Unix/Linux Solutions for your Business=20 = >+-----------------------------------------------------------------------= =20 >=20 >=20 >--__--__--=20 >=20 >Message: 2=20 >From: Mihai Secasiu <mih...@de...>=20 >Organization: Denix Solutions=20 >To: ssh...@li...=20 >Subject: Re: [Ssh-sftp-perl-users] Net::SFTP error handling - patch?=20 >Date: Sun, 12 Dec 2004 20:20:42 +0200=20 >=20 >You can send the patch here, I will review it and merge it into the = code.=20 >On Friday 10 December 2004 23:48, David Robins wrote:=20 >> I'd like to add some error handling with the result of having = Net::SFTP's=20 >> put method return success (true)/failure (false), and perhaps some = other=20 >> patches too:=20 >>=20 >> - similar return for 'get' (unless there's no local file specified, = in=20 >> which case the file contents are returned) (as reported [not by me] = about=20 >a=20 >> year ago at http://rt.cpan.org/NoAuth/Bug.html?id=3D4610) - allow = warnings=20 >to=20 >> be redirected to a callback (or turned off), defaulting to warn for=20 >> backwards compatibility=20 >>=20 >> If these seem like a good idea I'll write up and submit a patch (if = I do,=20 >> where should I send it to, this list?)=20 >>=20 >> Thanks,=20 >=20 >--=20 = >+-----------------------------------------------------------------------= =20 >| Mihai Secasiu=20 >| http://denixsolutions.com/=20 >| Complete Unix/Linux Solutions for your Business=20 = >+-----------------------------------------------------------------------= =20 >=20 >=20 >=20 >--__--__--=20 >=20 >_______________________________________________=20 >Ssh-sftp-perl-users mailing list=20 >Ssh...@li...=20 >https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users=20 >=20 >=20 >End of Ssh-sftp-perl-users Digest=20 |