I am rather new to Perl and translating some bash scripts to parse Apache logs from several remote production servers into a more useful format for processing on a local machine. I need to keep the production servers as uncluttered as possible. As such, I have two separate .pl files on my local machine - crawler.pl (formerly crawler.sh), responsible for the grabbing the useful information from the production servers, and reporter.pl (formerly reporter.sh), responsible for running the crawler and collating the information retrieved from the production servers.
What I'm looking to accomplish is the Perl equivalent of:
ssh "user@host" 'bash -s' < $crawler
where $crawler is (was) the physical location of crawler.sh on the local box.
I want reporter.pl to open an ssh connection the the production servers and remotely execute crawler.pl., something to the effect of:
use Net::SSH qw(ssh);
ssh($loginString,"perl -e $crawler");
which obviously doesn't work, but hopefully you understand what I'm driving at.
I know it's possible to accomplish this by copying the crawler file to the production servers and deleting it when it has completed its tasks; I'm after a more elegant solution, should one exist.
If you're not passing arguments to the script, it should be as simple as
ssh "user@host" perl < $crawler
If you want to pass command line args, just use a "-" placeholder to get the same affect as the bash -s, i.e.
ssh "user@host" 'perl - arg1 arg2' < $crawler
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!Donate Us With