2

I'm trying to turn a headless Pi into a single purpose computer. The application I wrote uses a ncurses GUI and I want it to start on boot. The program also needs to be run on a separate 'screen' (same physical screen, seperate window) using the 'screen' application. The reason being so I can view the output of the same application on two separate screens.

I've used various renditions of /etc/init.d/example.sh, but nothing seems to work properly. The program starts, but not in a new screen. Instead, the terminal screen shows the last part of the boot sequence chopped up. If I exit the screen session, the Python application appears, but is buggy.

Here is an example of the shell script:

start)
echo "Starting LAM!"
screen -S test -X test python /home/pi/cur.py
;;

Almost everything above and below this is commented out and in the 'skeleton'. I've been trying to make this work for 3+ hours with no success. If someone could help me it would be greatly appreciated.

3 Answers 3

1

screen programs do not really work well with init.d/ start/stop/restart logic, you may have more success trying to start your program from /etc/rc.local, just don't forget to make it an executable file.

1

Lenik, thank you for your reply, but I ended up discovering the answer. I needed the screen to display the program and remain on it after login (sorry for not mentioning).

What I did:

First, I auto logged in by altering a line in the /etc/inittab script file from:

1:2345:respawn:/sbin/getty --noclear 38400 tty1

to:

1:2345:respawn:/sbin/mingetty --autologin pi --noclear tty1

make sure to apt-get 'mingetty':

sudo apt-get install mingetty

Then after rebooting, the Pi automatically logged the user 'pi' in. After this I went to:

cd /home/pi/.profile

and added to the end of the script the line:

screen python /home/pi/cur.py

but I needed the program to restart if it crashed, so I put the previous command in a infinte loop as follows:

for (( ; ; ))

do

-- sudo screen python /home/pi/cur.py

done

After all this I restarted the Pi and it worked as I wanted.

0

Persistent/Flexible screen

xterm -name XTerm -title PICKANAME -geometry 200x20 -e 'screen -dURS PICKANAME -X python /path/to/script.py

The above command will open an xterm window of a specific size and title and open the screen session. If such a session does not exist, it will be created. If the session is opened elsewhere, the screen will be detached and re-attached to the newly created XTerm.

Startup

If you want for the screen to be available at startup, you can add it to your Startup Applications or you can add it to /etc/rc.local. If you add it to your rc.local file, be sure to detach the process.

screen -dURS PICKANAME -X python /path/to/script.py &

or

screen -dURS PICKANAME -X python /path/to/script.py && disown

Your Answer

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

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