SBC4 Python output to console screen

General PhidgetSBC Discussion.
Post Reply
tspeicher
Fresh meat
Posts: 2
Joined: Sun Aug 17, 2014 7:54 pm
Contact:

SBC4 Python output to console screen

Post 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:
print("test")
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.

-Terry
User avatar
Patrick
Lead Developer
Posts: 634
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: SBC4 Python output to console screen

Post by Patrick »

echo to /dev/tty1, this prints out on the attached HDMI monitor.

-Patrick
tspeicher
Fresh meat
Posts: 2
Joined: Sun Aug 17, 2014 7:54 pm
Contact:

Re: SBC4 Python output to console screen

Post 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!

-Terry
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests