On win32/cygwin, how to determine whether fd (stdin) has input? 
Author Message
 On win32/cygwin, how to determine whether fd (stdin) has input?

I'd like to read from stdin, but only if there is input present.  From reading
the FAQs, I get the impression that the Term::ReadKey package would be useful
for this, but I find that I cannot build it on win32/cygwin.  I also tried the
"select" solution (the first suggestion in the "How can I tell if there's a
character waiting on a filehandle?" question), but that seems to always return
"-1", whether there is really input available or not.


Fri, 24 Jan 2003 03:00:00 GMT  
 On win32/cygwin, how to determine whether fd (stdin) has input?
[Posted and e-mailed.]


) I'd like to read from stdin, but only if there is input present.
) From reading the FAQs, I get the impression that the
) Term::ReadKey package would be useful for this, but I find that
) I cannot build it on win32/cygwin.

) I also tried the "select" solution (the first suggestion in the
) "How can I tell if there's a character waiting on a filehandle?"
) question), but that seems to always return "-1", whether there
) is really input available or not.

select() on Win32 is only a "WinSock" call and so only works on
sockets, which STDIN is _not_ likely to be.

On Win32, you could use Win32::Console, but that doesn't come with
cygwin perl.  I haven't tried to build it under cygwin, so you
might want to try it -- it might actually work.

You could post the errors you got trying to build Term::ReadKey
under cygwin in hopes that those are problems that can be
overcome.
--
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)



Fri, 24 Jan 2003 03:00:00 GMT  
 On win32/cygwin, how to determine whether fd (stdin) has input?


    David> like to read from stdin, but only if there is input present.  ) From
    David> reading the FAQs, I get the impression that the ) Term::ReadKey
    David> package would be useful for this, but I find that ) I cannot build it
    David> on win32/cygwin.

    David> ) I also tried the "select" solution (the first suggestion in the )
    David> "How can I tell if there's a character waiting on a filehandle?"  )
    David> question), but that seems to always return "-1", whether there ) is
    David> really input available or not.

    Tye> select() on Win32 is only a "WinSock" call and so only works on
    Tye> sockets, which STDIN is _not_ likely to be.

    Tye> On Win32, you could use Win32::Console, but that doesn't come with
    Tye> cygwin perl.  I haven't tried to build it under cygwin, so you might
    Tye> want to try it -- it might actually work.

    Tye> You could post the errors you got trying to build Term::ReadKey under
    Tye> cygwin in hopes that those are problems that can be overcome.

I've actually gotten through building ReadKey.  I was missing a path entry, and
I was missing the "cygipc" package.

However, I now have a problem based on my misinterpretation of what "ReadKey"
does.  Of course it reads and consumes a key, but I need to only determine
whether input is present.  Is there an easy way to make it nondestructively
read?  I didn't see anything obvious in the ReadKey man page.  Alternatively,
is it feasible/possible to "ungetc" the character to the file descriptor?



Sat, 25 Jan 2003 03:00:00 GMT  
 On win32/cygwin, how to determine whether fd (stdin) has input?

[Posted and e-mailed.]

) I'd like to read from stdin, but only if there is input present.
) From reading the FAQs, I get the impression that the
) Term::ReadKey package would be useful for this, but I find that
) I cannot build it on win32/cygwin.

) I also tried the "select" solution (the first suggestion in the
) "How can I tell if there's a character waiting on a filehandle?"
) question), but that seems to always return "-1", whether there
) is really input available or not.

select() on Win32 is only a "WinSock" call and so only works on
sockets, which STDIN is _not_ likely to be.

On Win32, you could use Win32::Console, but that doesn't come with
cygwin perl.  I haven't tried to build it under cygwin, so you
might want to try it -- it might actually work.

You could post the errors you got trying to build Term::ReadKey
under cygwin in hopes that those are problems that can be
overcome.

--
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)



Sat, 25 Jan 2003 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. creating secondary index in paradox table at runtime??

2. Database programming with Pascal

3. Determining whether a process is interactive

4. determining whether a server supports secure authentication

5. Determining whether direcotry or file

6. How do I know whether a user specify STDIN or command invocation argument filename

7. Polynomial Curve Fitting

8. having problems reading STDIN

9. How to determine if input was pipe'd

10. Delphi, ADO and Oracle 8

11. TQuery RecordCount property

12. edit images

 

 
Powered by phpBB® Forum Software