Re: Read a single byte from stdin
On Tue, 14 Jul 2009, Martin Gregorie wrote:
On Mon, 13 Jul 2009 23:56:23 +0100, Tom Anderson wrote:
Nope. And if it did, it wouldn't do what you want - those key events can
only come from X, so if there's no X, there are no key events.
OK, sounds like it may have to be JINI then, and the POSIX incantation
from my 'codes' utility.
I'd suggest using JNI instead of Jini, though. :)
You're talking about "a headless machine" here, which suggests that
there's a particular machine in mind and portability isn't a
No particular machine in mind, just one with either no graphical X
libraries or running at init level 3 though I don't see a need to handle
serial terminals - just the console and ssh or telnet sessions. ssh
could include PuTTY, which has no graphical capability.
Still, if you know it's always going to be a POSIX machine, then the JNI/C
approach doesn't lose you any real value here.
Or, how about making your app use a socket, then connecting to it with
telnet? It's a bit Heath Robinson, but i think that should give you a
character at a time, provided your telnet is cooperative.
Ideally it would work from a command line in a normal login session,
which rather negates the socket idea.
Sorry, i didn't explain myself very well (ie at all) there. I was thinking
of a wrapper script which looks like:
java MartinApp -Dtelnet.port=$MARTIN_PORT &
sleep 5 # wait for server socket to come up
telnet localhost $MARTIN_PORT # user interacts with this
kill $APP_PID # ask for graceful shutdown ...
wait # ... and wait for it to happen
In other news, has anyone here read Blindness? Does it get better after
the 30 page mark, is does the whole thing read like a sentimental fairy
tale for particularly slow children? -- Abigail