in reply to Re: Using IPConfig
in thread Using IPConfig

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!!!