I want to download an executable and execute it in one step, while providing arguments to the executable.

I managed to figure out to download+execute by using a pipe:

wget -O - http://xrl.us/cpanm | perl

This executes the cpanm executable via perl.

Now I want to add an argument, say A:

wget -O - http://xrl.us/cpanm | perl A

This no longer works. I am now getting Cannot write to ‘-’ (Success)..

How can this be done?


You can put perl script arguments after programname which in this case is the standard input (-). So, I think, this is what you ask:

wget -O - http://xrl.us/cpanm | perl -- - A


wget -O - http://xrl.us/cpanm | perl -- - --help

See: perlrun man page for more details.

Note: From the manual page:

A "--" signals the end of options and disables further option processing. Any arguments after the "--" are treated as filenames and arguments.

In other words, -- terminates the perl arguments. After that we put the file name containing the script (in our case this is the standard input which is indicated by a -) and then the arguments to the script.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.