http://www.perlmonks.org?node_id=74268

bsummerer has asked for the wisdom of the Perl Monks concerning the following question:

I looked on the site search and tutorial on how to do this, but searching for "command line" gives me perl execution options...

Anywho, I put together a script that pings an URL then if it's dead, it logs the error and runs a netstart/netstop from the command line. Haven't figured that part out yet. If I'm running the script at, say c:\ and I want to run a file called "something" with the arguements "this and that", how would I do that (essentially what is the perl equivalent of "execvp(argv[0],argv)" in c++?)

Edited 2001-04-20 by Ovid

Replies are listed 'Best First'.
Re: I'm an idiot newbie, so
by Chady (Priest) on Apr 20, 2001 at 22:53 UTC
    are you searching for exec ??
    He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.
      Didn't know if that was even a keyword. Many thanks. -Brett

        Beware that exec never returns (if you didn't already know that), because it replaces your process with the new one.

        If you want to make multiple "execs", you can use system.

        Check out perlfunc for a list of all available functions and keywords in Perl.

        bbfu
        Seasons don't fear The Reaper.
        Nor do the wind, the sun, and the rain.
        We can be like they are.

        Just to complete chady and bbfu answers.
        backticks quotes could be handy too...
        (When you need to grab the produced output)

        You might then use something like :
        $string_to_process=`ping $host`;
        (notes that variable are interpolated inside backticks)

        "Only Bad Coders Badly Code In Perl" (OBC2IP)
Re: I'm an idiot newbie, so
by Beatnik (Parson) on Apr 21, 2001 at 02:46 UTC
    Try @ARGV... the first parameter is $ARGV[0], second is $ARGV[1] etc. You also might wanna look at Getopt::Long and Getopt::Std. More info, check here

    Greetz
    Beatnik
    ... Quidquid perl dictum sit, altum viditur.
Re: I'm an idiot newbie, so
by Tuna (Friar) on Apr 21, 2001 at 02:08 UTC
    Kinda off topic, but, there's no need to be self-deprecating :) Every person here wrote code for the first time, or was a "newbie", once.
Re: I'm an idiot newbie, so
by diskcrash (Hermit) on Apr 21, 2001 at 21:33 UTC
    Dear bsummerer-

    A good question and I know you WAY too well to agree that you are an "idiot newbie". Let us know how it worked out.

    -diskcrash