I want to display text output on the console that is always displayed on a small screen 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 
  • Weird. Does tee /tmp/capture.txt >/dev/tty1 work?
    – dhag
    Commented Mar 17, 2015 at 17:00
  • Nope :( , this doesn't work either: /home/pi/python_test_scripts_linux/test_wrapper.py | tee /tmp/capture.txt > /dev/tty1
    – PhilBot
    Commented Mar 17, 2015 at 17:07
  • Ok - so where is your output going then? Are you not writing to stdout? Do you open() a descriptor in your script and write to it? tee will only tee its stdin. If you can figure out where you are writing then you can dup it. What is up with all of the sudo nice stuff? You can just tail /dev/vcs1 if you must, but you're doing some weird stuff. Can you drop all of the sudo stuff and still print?
    – mikeserv
    Commented Mar 17, 2015 at 20:26
  • Have you tried redirecting the standard output? .../test_wrapper.py 1>/dev/tty1 1>/path/to/file
    – YoMismo
    Commented Mar 18, 2015 at 14:14

2 Answers 2


If you want to save the output of a command, use the script command

script -c "your command" /tmp/capture.txt

The output will be sent to the tty and also to capture.txt

If tty1 is not the console that you are running from, you could run a

tail -F /tmp/capture.txt 

from that tty in order to get the results there as well.

  • Hi Robert - thanks for the input. I tried launching this over an SSH terminal: 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
    – PhilBot
    Commented Mar 17, 2015 at 19:54
  • However, the text that is redirected to /dev/tty1 does not get captured in the /tmp/capture.txt file. Only errors if I kill the process. Any other ideas?
    – PhilBot
    Commented Mar 17, 2015 at 19:55
  • Don't redirect to /dev/tty, redirect to /tmp/capture. Then try tail -F /tmp/capture > /dev/tty1 & . Start the tail first in background. and kill when done. Commented Mar 17, 2015 at 19:59
  • thanks for the suggestion but it had the same effect. /dev/tty1 must be special?
    – PhilBot
    Commented Mar 17, 2015 at 20:10
  • Check to see if you have permission to write to the tty. "ls -l /dev/tty1". Fix permission if required. Commented Mar 20, 2015 at 18:29

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
  • This just solves the problem for a python script output. @Robert Jacobs answer is more genral and seems to be the real answer to your question (which was not specific about python).
    – Michael P
    Commented May 19, 2023 at 11:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .