in reply to Re^2: cpan module to do stuff remotely
in thread cpan module to do stuff remotely

Net::SSH, or the OO Net::SSH::Perl is easy to use:

#!/usr/bin/perl -wT use Net::SSH::Perl; use feature qw( say ); my $ssh = Net::SSH::Perl->new( "1.2.3.4" ); $ssh = Net::SSH::Perl->new( "my.host.name" ); #You can use a hostname $ssh->login( "zaphod", "twoheads2" ); my($stdout, $stderr, $exit) = $ssh->cmd( "cat /dev/universe" ); say "The command said: $stdout"; say "The command error'd: $stderr"; say "The command's exit status was $exit";

You can always do it yourself if you really must, with IO::Socket, or even Socket if you dare.

~Thomas~
confess( "I offer no guarantees on my code." );

Replies are listed 'Best First'.
Re^4: cpan module to do stuff remotely
by Steve_BZ (Chaplain) on Jun 06, 2012 at 01:05 UTC

    Hi Thomas,

    Ok, I can see what it's doing. Thanks for the sample code.

    It looks great if I could use it. It's exactly how I would like to operate, but I have no way of getting through the remote firewall, the machine could be in a hotel or a hospital with a wireless router and also no way of port-forwarding my connection to the remote machine.

    So I think it needs to be *pulled* by the remote host. My local machine, also behind a router/firewall, then needs to post a file or files on a convenient server, the remote host will regularly check the server, download and execute the code.

    So it's really only the my($stdout, $stderr, $exit) = $ssh->cmd( "cat /dev/universe" ); bit that I want.

    So I probably need to use Net::FTP to download the file(s) according to some sort of schedule. And then maybe IPC::RunExternal for each line.

    What do you think?

    Thanks for your input.

    Regards

    Steve.

      I have no way of getting through the remote firewall
      That is a network issue that you will have to work out with your network admin, or if that is you, figure out on your router. That, however, is out of this forum's scope.

      What do you think?
      Well, I don't know. If that accomplishes your goal, then that is the way to go. And don't limit yourself to Perl. Sometimes, cron can be a better and more reliable alternative, plus it is built in to your OS. On Windoze, you would use the task scheduler or what have you.
      On an unrelated side note: Windoze is terrible for programming anything useful on.

      ~Thomas~
      confess( "I offer no guarantees on my code." );

        On an unrelated side note: Windoze is terrible for programming anything useful on.

        Never heard of it, I get plenty done on NT5