user1074051 user1074051 - 8 months ago 46
Perl Question

how to retrive a perl file using wget and execute it using a one-liner?

I'm looking to use wget to retrieve a perl file and execute it in one line. Does anyone know if this is possible/how I would go about doing this?

Answer Source

In order to use wget for this purpose, you would use the -O flag and give it the '-' character as an argument. From the manpage:

-O file

Giving '-' as the "file" option to -O tells it to send it's output to stdout, which can then be piped into the Perl command.

You can provide the -q flag as well to turn off wget's own warning and message output:

   Turn off Wget's output.

This will make things look cleaner in the shell.

So you would end up with something like:

wget -qO - | perl -

For more information on I/O redirection take a look at this: