in reply to Re: run perl script with cmd line in shell
in thread run perl script with cmd line in shell

Is there a reason why something like ssh user@server perl - $cmdlinArgtoscrpt < script.pl would not work?

use Data::Dumper; print Dumper(\@ARGV); # testing: $ ssh someserver perl - aoeu snth < localscript.pl $VAR1 = [ 'aoeu', 'snth' ];

Replies are listed 'Best First'.
Re^3: run perl script with cmd line in shell
by Anonymous Monk on Apr 16, 2012 at 19:35 UTC

    Just wanted to add that due to the way ssh executes commands, you may need to shell-quote your command line arguments twice if they have _any_ odd characters:

    % ssh someserver perl - "foo bar" < localscript.pl $VAR1 = [ 'foo', 'bar' ]; % ssh someserver perl - "foo (bar)" < localscript.pl bash: -c: line 0: syntax error near unexpected token `(' bash: -c: line 0: `perl - foo (bar)' % ssh someserver perl - '"foo (bar)"' < localscript.pl $VAR1 = [ 'foo (bar)' ];
      This Solution worked well
Re^3: run perl script with cmd line in shell
by Anonymous Monk on Apr 18, 2012 at 08:22 UTC
    -->>ssh user@server perl - $cmdlinArgtoscrpt < script.pl Worked well, thanks