Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: run perl script with cmd line in shell

by MidLifeXis (Prior)
on Apr 16, 2012 at 13:31 UTC ( #965314=note: print w/ replies, xml ) Need Help??


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

3)Embed the command line arguments into the top of your script.pl, perhaps as you are sending it across the wire to perl. This would require some pre-processing of the script and some assumptions of where you can embed the code - if I were to do it this way, I would probably have a token of some sort in the script that I would replace with my parameters --> The cmd line argumetns are also dynamic in nature..but i dont understand this entire statment correctely. can you give an example ?

In your script you could have something like:

# Earlier stuff in the script... # Fill in the arguments if running remotely @ARGV ||= qw(%%REPLACEDTOKEN%%); # ... and back it out if @ARGV should really be empty @ARGV = () if $ARGV[0] eq "\%\%REPLACEDTOKEN\%\%"; # Rest of your script
At this point, you would use something locally to replace '%%REPLACEDTOKEN%%' with your parameters, and pipe that to a perl call on the remote machine.

sed -e .... < script.pl | ssh user@remote perl

I still have concerns that this is the most robust solution to your problem.

Do your scripts use any temporary files? If so, I would seriously reconsider your answer to number 2. If you can write temp files, you can also write a temporary perl script.

--MidLifeXis


Comment on Re^3: run perl script with cmd line in shell
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2014-08-23 02:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (171 votes), past polls