Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: run perl script with cmd line in shell

by i5513 (Pilgrim)
on Apr 16, 2012 at 22:43 UTC ( #965407=note: print w/replies, xml ) Need Help??

in reply to run perl script with cmd line in shell


Take a look at Net::OpenSSH or other cpan ssh modules.

It is not exactly what do you want to do (perl will running in this case in your computer and not in remote), but I hope it helps.

It can be useful in many environments, like:

  • You don't have the same perl version in all your hosts
  • You want to parse some remote file or some remote command output
  • You want to write remote files with some info
  • See this example which is like a first attemp to solve your problem (cat | perl thisexample user@host parameters):

    #!/usr/bin/perl -w use strict; use Net::OpenSSH; my $ssh = Net::OpenSSH->new($ARGV[0]); $ssh->error and die "Couldn't establish SSH connection: ". $ssh->error; shift; my (@args)=@_; shift while (@ARGV!=0); my $command=""; while (<>) { $command.=$_; } $ssh->system("perl - <<EOS @args $command; EOS ");

    For solve this specific issue, I prefer the response that Anonymous monk give you before (Re^2: run perl script with cmd line in shell), it is clearest.


    Log In?

    What's my password?
    Create A New User
    Node Status?
    node history
    Node Type: note [id://965407]
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others lurking in the Monastery: (4)
    As of 2018-01-19 20:24 GMT
    Find Nodes?
      Voting Booth?
      How did you see in the new year?

      Results (222 votes). Check out past polls.