Esteemed monks,
I'm running traceroute with open(), trying to read from the filehandle with select() and sysread(). The idea is to get the output in a nonblocking fashion.
The code below works in my Linux box. But I cannot get select to read anything in Windows Vista ( Activestate 5.10 ).
I'm pretty sure that I'm doing something inherently wrong with select and then sysread().
Can you comment on the code below and provide some options? Why is it not working with Windows?
Thanks!!
use strict;
use IO::Select;
use IO::Handle;
use Time::HiRes qw(usleep);
$| =1 ;
my $pingout ;
open($pingout, '-|', "tracert www.google.com");
if($pingout){
my $select = IO::Select->new();
$select->add($pingout);
while (1) {
print "loop\n";
my $line;
if (my @ready = $select->can_read(0) ) {
foreach(@ready){
$_->sysread($line, 2048);
print $line,$/;
}
}
usleep(100000); # 100 ms
}
}
------------------------------
"geneva will not marry you no matter how much you love Larry Wall."
Geneva Wall
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.