Re: [Ssh-sftp-perl-users] Multiple operations in a single channel/shell? (Net::SSH)
Brought to you by:
dbrobins
|
From: Mihai S. <mih...@de...> - 2004-12-12 18:16:52
|
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) = $ssh->cmd("export FOO=WIBBLE");
> ($out2,$err2,$rc2) = $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
+-----------------------------------------------------------------------
|