in reply to cpan module to do stuff remotely

I am looking at Net::SSH::Perl and Sys::Manage::Desktops, but I'm not sure yet whether they meet my needs
What does that mean, "do not meet my needs"? Net::SSH is tried and true, has great CPANRatings, appears to test correctly on almost every system(according to CPANTesters), and has worked for me in the past.
What is your criteria?

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

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

    Hi Thomas,

    Well I think I said but I'm not sure yet whether they meet my needs. My needs are to run commands, trap errors and log output (as above) and I need to work through a firewall. I haven't tested Net:SSH yet, but it seems to be interactive and I'm not sure how you connect through a gateway if you don't have a dedicated IP address for the machine being maintained and the ports aren't forwarded. As I say I need to do some checking. Maybe it does everything I need.

    At the moment, I imagine the remote programme with regularly check a file on a website and execute the instructions in it.

    Regards

    Steve

      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." );

        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.