in reply to Using IPConfig

The easiest way would be to use backticks to execute the application and capture the output.
my $ipconfig = `ipconfig /renew`; # test the output of the ipconfig command here.

Replies are listed 'Best First'.
Re^2: Using IPConfig
by ghenry (Vicar) on Apr 11, 2005 at 15:22 UTC

    I am a beginner, so beware.

    When I do this, I would do:

    my $ipconfig = `ipconfig /renew`; my $ipcfg_success = $?; if ($ipcfg_success == 0) { do something; } else { do something; }

    or, to test:

    my $ipconfig = `ipconfig /renew`; my $ipcfg_success = $?; die "command failed: $?" unless $ipcfg_success == 0;

    If these are wrong, please say so, so I don't do them again ;-)

    But remember, $? is the status returned by the last pipe close, backtick (``) command, successful call to wait() or waitpid(), or from the system() operator. Therefore, be careful where you put it, i.e. don't define it at the top of your program and expect it to work.

    For $? see perlvar and for other ways to execute commands, see exec and system functions.

    Thanks.

    Walking the road to enlightenment... I found a penguin and a camel on the way.....
    Fancy a yourname@perl.me.uk? Just ask!!!