Page 1 of 1

SBC4 Python output to console screen

Posted: Fri Jun 07, 2019 9:39 am
by tspeicher
I am able to run a Python3 script at system startup on my SBC4. I added the following line in the /etc/rc.local file, right before the exit(0) line at the end:

(sleep 60 ; echo $(date) >> lastboot; /usr/bin/python3 /root/testBoot. py)&

Without going into a nauseous amount of detail, this line (consisting of 3 commands) does run correctly. It sleeps for 60 seconds to make sure the system completes the boot process, adds the current timedate stamp to a file called lastboot, then runs the Python3 script "testBoot. py". "testBoot. py" does two small tasks: it prints an output to the screen and prints an output to a file; this way, I can make sure the python script is running by the presence of the file it created.

My problem is not being able to get any of the output from my Python script to go to the console. I have tried several different methods of sending output from the script, but none have worked.

I've tried:
import sys, sys.stdout.write("Hello")
import os, os.system("echo test")
import os, os.system("echo 123456 > /dev/tty")

I'm not a total noob, but I am only a novice with regards to standard outputs on linux.

However, the above method (Python3 script in rc.local) prints to the console correctly on a Raspberry Pi.

I know the Phidget Web GUI will let me run a script on startup, but that stdout is redirected to the web page view, and I need to see output on the terminal.

Any help is greatly appreciated.


Re: SBC4 Python output to console screen

Posted: Mon Jun 10, 2019 2:21 pm
by Patrick
echo to /dev/tty1, this prints out on the attached HDMI monitor.


Re: SBC4 Python output to console screen

Posted: Mon Jun 10, 2019 3:38 pm
by tspeicher
You 'da Man!!

Thanks, Patrick. That was the problem. I tried /dev/tty, but I was missing the '1' on the end. As soon as I did the output to /dev/tty1, it worked!!

Of course, now, I see on bootup that the Phidget says "/dev/tty1" at the top of the screen.

Thanks for your help!