I have a utility foo
that I want to grep output from, redirect, and otherwise do all the normal text manipulation stuff. But alas! Look at what it does...
$ foo
bar
$ foo > /dev/null
bar
$ foo 2> /dev/null
bar
$ foo | grep abc
bar
$ foo 2| grep abc
bar
Apparently the output is neither stdout
nor stderr
. Perhaps foo
rights directly to the tty instead of to stdout. There is an answer here that provides a workaround using script -c
. But alas again!
$ script -c foo > /dev/null
script: illegal option -- c
usage: script [-a] [file]
Perhaps my script
utility is not the full version. The operating system is QNX.
For those of us who cannot use the script -c
workaround, how can we easily capture the output? Is there a way to redirect the tty file itself, if that makes any sense?
Is it possible to do something like foo (/dev/ttyp0)| grep abc
? That likely will not work exactly as shown, but is there a way to do something similar? An answer which requires the file to be redirected first (if that is even possible) is fine, so something like /dev/ttyp0 please go to /dev/null ; foo
is ok.
Ultimately, I would like to be able to pipe the output of foo
to grep
and/or redirect foo
output to a file.
SHELL=/your/program script ...
. – Jun 14 '19 at 23:54script
insists to run/bin/sh
or your login shell, it could tricked via theENV
variable to source a file with callsexec /your/program
. What is the shell on qnx? – Jun 14 '19 at 23:55/your/program
doesn't accept or interprets the-i
option specially, you could write a wrapper for it. – Jun 14 '19 at 23:57script
if that works. Unfortunately I don't have a QNX system to test on. – Kusalananda Jun 15 '19 at 00:21