select on NT question
William Atkinson
CWA at DISC.com
Tue Jan 18 13:11:31 CST 2000
Greetings,
I'm trying to use select to read from a pipe on NT. When I run the same
script on Linux it works of course. Does anyone know if I'm doing something
grossly wrong or if this functionality is not supported?
Thanks in advance,
Chip
Here's the script:
#!/usr/bin/perl
use strict;
use IO::Select;
use IO::File;
use IO::Handle qw (_IONBF);
use vars qw ($fh $select @ready);
use vars qw ($can_loop);
$| = 1;
$fh = new IO::File ("./datescroll 1 |");
if (defined ($fh))
{
print ("Opened file. Yay\n");
}
$select = new IO::Select ($fh);
$fh->setbuf (_IONBF);
$can_loop = 1;
while ($can_loop == 1)
{
# If I just put this in on NT, I can actually get the output of the
# datescroll script.
#
# print ("Count of select handles: ", $select->count, "\n");
# print ($fh->getline);
if (@ready = $select->can_read)
{
foreach $fh (@ready)
{
if (!eof ($fh))
{
print ($fh->getline);
}
else
{
$can_loop = 0;
}
}
}
}
undef ($fh);
-----------------------
Here's datescroll:
(I put the date > datefile in to prove that the script ran even if the
output never made it to the perl script)
#!/bin/sh
if [ $# -eq 0 ]; then
time=1
else
time=$1
fi
date > datefile
let i=1
while :; do
echo $i $(uname -n) $$
let i=$((i + 1))
sleep $time
if [ $i -gt 5 ]; then
date >> datefile
exit
fi
done
More information about the Boulder-pm
mailing list