Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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.

    Comment on Re: run perl script with cmd line in shell
    Download Code

    Log In?

    What's my password?
    Create A New User
    Node Status?
    node history
    Node Type: note [id://965407]
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (12)
    As of 2016-04-29 16:35 GMT
    Find Nodes?
      Voting Booth?
      :nehw tseb si esrever ni gnitirW

      Results (441 votes). Check out past polls.