Start a program and get a hold of it's STDOUT and STDIN?



Hello. I am trying to write a logging program to wrap around a server
program that we need that doesn't have logging capabilities of it's own.
Normally, one would just redirect it on the command line:

../server 2>&1 logfile.log

But this doesn't have any dating what so ever and it can get hard to
read as it grows.

My goal is to start the program from my program and get both it's
STDOUT/ERR and STDIN, that way my program can see live Output as it
comes in from the server and also respond to certain events (the server
accepts console commands when it is normally run in the foreground, so
it can be fully interactive, accepting command via STDIN normally.

I've been search all over (perldoc, google, etc) and all I could find
was examples of getting STDIN or STDOUT (using pipes) but not both at
the same time. Further mode, I need this to be in real time (when the
server spits out something to STDOUT/ERR I want my program to
immediately get this, and then process it (add a line to the log file,
perform some processing if a certain event occurs, such has a new
connection, etc.)

Thank for any help.


.



Relevant Pages

  • Re: Start a program and get a hold of its STDOUT and STDIN?
    ... My goal is to start the program from my program and get both it's STDOUT/ERR and STDIN, that way my program can see live Output as it comes in from the server and also respond to certain events (the server accepts console commands when it is normally run in the foreground, so it can be fully interactive, accepting command via STDIN normally. ... Further mode, I need this to be in real time ...
    (comp.lang.perl.misc)
  • Re: Start a program and get a hold of its STDOUT and STDIN?
    ... > STDOUT/ERR and STDIN, that way my program can see live Output as it ... > comes in from the server and also respond to certain events (the server ... > it can be fully interactive, accepting command via STDIN normally. ...
    (comp.lang.perl.misc)
  • Re: Start a program and get a hold of its STDOUT and STDIN?
    ... I am trying to write a logging program to wrap around a server ... one would just redirect it on the command line: ... >> STDOUT/ERR and STDIN, that way my program can see live Output as it ... >> STDIN normally. ...
    (comp.lang.perl.misc)
  • Re: Start a program and get a hold of its STDOUT and STDIN?
    ... I am trying to write a logging program to wrap around a server ... > Does the wrapper program actually need to process any commands before ... my wrapper needs to process OUTPUT coming FROM the server ...
    (comp.lang.perl.misc)
  • Re: Start a program and get a hold of its STDOUT and STDIN?
    ... I am trying to write a logging program to wrap around a server ... >>> program that we need that doesn't have logging capabilities of it's ...
    (comp.lang.perl.misc)