Output is in console but not part of stdout or stderr

outputstderrstdout

I have a command that outputs the following:

READY
Listening....
HELLO
READY
Listening....
TEST

It is speech recognition from pocketsphinx_continuous.

I need that output redirected to a file, and it does not seem to be comming from stdout or stderr because I have tried adding 1>log.txt and 2>log.txt and every time they are blank.

Here is the kicker: when I add 1>log.txt to the command, there is no longer any output to the console, but log.txt is still blank.

Also, when I add | tee log.txt it does not show up in the console and the file is still blank.

Is this output coming from stdout, if so, why is it not being redirected to the file?

This question is related to my other question here: Redirect Output of Pocketsphinx_continuous to a file

Pocketsphinx is weird and using it's arguments to redirect output is not possible for me, in this question I just want to know where this output is coming from sdtout or sdterr or some other place, and how to redirect that output.

EDIT

ls -l /proc/PID/fd/ returns:

lrwx------ 1 pi pi 64 Jan  4 04:12 0 -> /dev/pts/2
lrwx------ 1 pi pi 64 Jan  4 04:12 1 -> /dev/pts/2
lrwx------ 1 pi pi 64 Jan  4 04:11 2 -> /dev/pts/2
lrwx------ 1 pi pi 64 Jan  4 04:12 4 -> /dev/snd/pcmC0D0c

Best Answer

The hideous command:

script -q -f -c "pocketsphinx_continuous -samprate 48000 -nfft 2048 -hmm /usr/local/share/pocketsphinx/model/en-us/en-us -lm 9745.lm -dict 9745.dic -inmic yes -logfn /dev/null" words.txt &

works for me, it logs:

READY....
Listening...
HELLO

to the file, and it is easy to weed out the unwanted stuff.

EDIT: If anyone is doing this themselves in the future, remove the & at the end of that command if you are executing it in a console, if you are executing it via Python or another language, keep the & at the end.

Related Question