I want to display text output on the console that is always displayed on a small screen ( Adafruit 2.8 Inch TFT ) on my Raspberry Pi.

The following code works for showing that text output:

cd /home/pi/python_test_scripts_linux && sudo nice -n -20 /home/pi/python_test_scripts_linux/test_wrapper.py > /dev/tty1

Now I want to capture the output in parallel with seeing it on the screen - I have tried 'tee' but that does not show text on the screen and also does not capture it to file:

cd /home/pi/python_test_scripts_linux && sudo nice -n -20 /home/pi/python_test_scripts_linux/test_wrapper.py | tee /dev/tty1 /tmp/capture.txt

How can I redirect the output of my script to /dev/tty1 so I can see it on my screen but also capture the output to file?


Per the answer below - I tried using 'script' - unfortunately it did not work:

script -c "cd /home/pi/python_test_scripts_linux && sudo nice -n -20 /home/pi/python_test_scripts_linux/test_wrapper.py > /dev/tty1" /home/pi/python_test_scripts_linux/report.html


I also tried to 'tail' the output of the file that I redirected the output to into /dev/tty1, but it also did not work:

sudo tail -F /home/pi/python_test_scripts_linux/report.html > /dev/tty1 &
cd /home/pi/python_test_scripts_linux && sudo nice -n -20 /home/pi/python_test_scripts_linux/test_wrapper.py > /home/pi/python_test_scripts_linux/report.html 
  • I think the tee command will do what you want. You can read the man page with the following command man tee. Can you try this cd /home/pi/python_test_scripts_linux && sudo nice -n -20 /home/pi/python_test_scripts_linux/test_wrapper.py | tee -a /dev/tty1 /tmp/capture.txt or cd /home/pi/python_test_scripts_linux && sudo nice -n -20 /home/pi/python_test_scripts_linux/test_wrapper.py | tee /dev/tty1 > /tmp/capture.txt you may also want to reverse the tty and file in the last one. For what it is worth this would be easier to debug if you made the stuff before the pipe to tee ls. Mar 18, 2015 at 2:53
  • this works for me ls | tee /dev/tty4 /tnp/lsout note I used ls to make debugging easier (less typing). Mar 18, 2015 at 3:35

1 Answer 1


Thanks for the input, it did not work for Python scripts because it was buffering the output.

This allows it to work with tee:

python -u ./myscript.py | tee /dev/tty1 /tmp/a.txt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.