in reply to Is SSH the only way to execute remote, one off PERL scripts?

If you're using Net::SSH::Perl then you're re-creating ssh on your machine, and all the encryption that entails in Perl, though Math::BigInt and Pari.

If you're using Net::OpenSSH you get the same functionality using ubuntu's implementation of SSH, which makes things a lot faster.

But, again, you should post your code, as always here at PerlMonks.

  • Comment on Re: Is SSH the only way to execute remote, one off PERL scripts?

Replies are listed 'Best First'.
Re^2: Is SSH the only way to execute remote, one off PERL scripts?
by adornach (Initiate) on Jul 24, 2010 at 23:20 UTC
    Thanks everyone for the replies.

    A quick update:

    I was indeed doing something wrong. I was printing out error and status messages for each step in my parsing loops. For a big scrape job like the one I'm in the midst of, this could be hundreds of thousands of lines which was causing Terminal to chew up RAM.

    So, I've commented out all but a couple critical lines and immediate symptom solved.

    However, I think the nohup suggestion will actually solve the problem. Not having to keep a terminal window and SSH session open after executing a script sounds like a dream!

    Thanks again!

      I'm glad that you found a solution. I had been working on this before you made your post. I thought that I'd post it just in case it gives you some ideas.

      I used Parallel::Runner to run 5 scrapers

      #!/usr/bin/perl use strict; use warnings; use Parallel::Runner; open STDOUT, '>', 'ssh.log' or die "Couldn't open ssh.log: $!\n"; my $runner = Parallel::Runner->new(5); $runner->run( sub { system("perl scraper1.pl") }); $runner->run( sub { system("perl scraper2.pl") }); $runner->run( sub { system("perl scraper3.pl") }); $runner->run( sub { system("perl scraper4.pl") }); $runner->run( sub { system("perl scraper5.pl") }); $runner->finish;
      Then I used this to check the log
      #!/usr/bin/perl use strict; use warnings; use Net::SSH::Perl; connectToServer(); sub connectToServer { my $host = 'remote_server'; my $username = 'user'; my $password = 'password'; my $cmd = 'cat /path/to/ssh.log'; my $ssh = Net::SSH::Perl->new( $host, protocol => '2,1', debug => 1, ); $ssh->login( $username, $password ); my ( $stdout, $stderr, $exit ) = $ssh->cmd($cmd); print $stdout, "\n"; }