Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Catching a direct redirect to /dev/tty

I'm working on an application controller for a program that is spitting text directly to /dev/tty.

This is a production application controller that must be able to catch all text going to the terminal. Generally, this isn't a problem. We simply redirect stdout and stderr. This particular application is making direct calls to echo and redirecting the result to /dev/tty (echo "some text" > /dev/tty). Redirects via my application controller are failing to catch the text.

I do have the source for this application, but am not in a position to modify it, nor is it being maintained anymore. Any ideas on how to catch and/or throw away the output?

like image 588
daniel Avatar asked Nov 20 '08 21:11

daniel


2 Answers

 screen -D -m yourEvilProgram

should work. Much time passed sinced I used it, but if you need to read some of its output it could even be possible that you could utilize some sockets to read it.

[Added: two links, Rackaid and Pixelbeat, and the home page at GNU]

like image 72
flolo Avatar answered Sep 22 '22 11:09

flolo


The classic solution to controlling an application like this is Expect, which sets up pseudo-terminals, does logging, and drives the controlled application from a script. It comes with lots of sample scripts so you can probably just adapt one to fit your needs.

like image 36
Colin Macleod Avatar answered Sep 20 '22 11:09

Colin Macleod