in reply to
run perl script with cmd line in shell
ssh user@server perl < script.pl $cmdlinArgtoscrpt
It appears that you are asking to have a perl command run the local script script.pl
with the parameters $cmdlinArgtoscrpt
. Is this correct?
Update: "Hello. My name is MidLifeXis, and I am a complexaholic." See Re^2: run perl script with cmd line in shell for a better solution.
I see various solutions to this, with different difficulties:
- Share the script to the remote machine and execute it from that shared location.
- Copy the script.pl to the remote machine and run it from there. There are potential race conditions between the copy / execute and the execute / cleanup.
- 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.
- Run the command remotely using the -e or -E flag to perl, and embedding the script on the remote command invocation. This would be my last choice for something that is any more complex than dead simple unless I could ensure that quotes were properly escaped, newlines handled, length of the command line accounted for, and so on.
Update: I do not mean to imply that these are the only solutions -- there may well be something much more elegant, robust, and maintainable than any idea proposed above.