I've found that under Windows 98 there seems to be a limit on the number of opens from a pipe that can be done. What I had was
use warnings;
$runcount = 0;
while(1) {
# see if there is an internet connection running
open(IPCONFIG,"ipconfig|") || fatal("Can't fork ipconfig");
$runcount++;
print "Good opens so far $runcount\n";
while(<IPCONFIG>) {
if (/IP Address/) {
($ipaddr) = /(\d+.\d+.\d+.\d+)/;
last;
}
}
close(IPCONFIG);
sleep 1;
}
sub fatal {
my ($rpt) = @_;
print STDERR "Fatal Error Report\n\n";
print STDERR "Reason $rpt\n";
print STDERR "Error $^E\n";
print STDERR "Good opens $runcount\n";
die;
}
This fails after 64 opens (a mystical number! but very small for these inflationary times). It was suggested to me that W98 fakes pipes by writing to a temporary file and then making the temporary file available for input. So I though the way round it was to make the command output available through backticks thusly
$res = `IPCONFIG`;
fatal("Call failed") if (!defined $res);
$runcount++;
($ipaddr) = ($res =~ /(\d+.\d+.\d+.\d+)/);
but this also fails on the 65th attempt. It looks as though backticks are faked also.
Two questions
1) does anyone know of a way around this and
2) can anyone confirm that W2000 doesn't suffer from this problem (I'm pretty sure that NT 5 doesn't but I'll have to wait until I'm back in work to try it)
Thanks in anticipation of another interesting thread.
Odud
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.