Feed on
Posts
Comments

to run a unix command in a perl script, use backticks. for example to call curl in perl:

`curl -o file.out “http://stinkpot.afraid.org:8080″`


Bookmark and Share

if that was helpful ...

check out the other tips and tricks i've compiled on these pages. you might learn something else interesting!

5 Responses to “run unix commands in perl”

  1. on 14 Sep 2006 at 9:32 am William

    Thanks for info. I’ve been looking for a way to do this.

  2. on 22 Oct 2006 at 6:20 pm Ali

    Another way to do this is by using thte function system. Something like:
    system(‘curl -o file.out “http://stinkpot.afraid.org:8080″’);

    The backticks are actually supposed to set a string to the output of a command. For example something like:
    @dirs = split(/\n/, `ls | more`);
    and therefore are blocking.

    If you include an & in the command given to system it will be non-blocking.

  3. on 22 Oct 2006 at 6:51 pm Lawrence David

    thanks for the info ali!

  4. on 09 May 2008 at 7:31 am 6f1cea4f6c5b

    6f1cea4f6c5b…

    6f1cea4f6c5b7f509c07…

  5. on 04 Jul 2011 at 12:54 am sweat

    may i know how to use unix command: “history” in perl script? where I need to list out the history of the unix command in a perl script.

Did I get this wrong? Let me know!

Trackback URI | Comments RSS