moz has asked for the wisdom of the Perl Monks concerning the following question:

Hi I am new to Perl and using SFTP in general. I am being required to use the NET::Foreign package as a means of file transfer by a project at work. My problem is that I am unable to issue other ssh commands like cmd() to perform other ssh tasks without opening up a system call to open a ssh session. This greatly slows things down in my application. I would like to open one connection using NET::Foreign and keep it open to be able to issue ssh commands and sftp commands. Is this possible? And how would I do it?

Replies are listed 'Best First'.
Re: NET::Foreign Commands
by salva (Canon) on Jan 28, 2015 at 16:00 UTC
      thanks for the timely reply salva. The problem is I must use a tectia ssh client which NET::Foreign supports. So when i make a system ssh call it has to use tectia's sshg3 client. Does Net::SSH2 support tectia?
        Tectia's clients reuse the connections transparently.

        If you call sshg3 while the SFTP connection is open, it would send the command through it (well, IIRC, unless you tell sshg3 explicitly to not do it with the --exclusive option).

        Also, the development version of my other module, Net::SSH::Any, has a backend for sshg3:

        use Net::SSH::Any; my $ssh = Net::SSH::Any->new($host, user => $user, password => $password, backend => 'Sshg3_Cmd'); $ssh->error and die "unable to connect to $host"; my $output = $ssh->capture('ls');

        Unfortunatelly, at this point, Net::SSH::Any integration with Net::SFTP::Foreign is broken.