Apps :: How Do I Run Python Scripts At DSL USBStick Bootup
For the sake of clarity and thoroughness, I thought I'd post my "final, first cut" on this topic.
I decided to start fresh, so I reinstalled DSL 0.8.2 on my PNY 256MB USB 2.0 USBStick/KeyDrive/PenDrive/ThumbDrive,
so that I could document the permission/ownership of bootlocal.sh, etc.
I also redid/restructured my Python script bootup files. I decided to go against robert's advice and I'm keeping my
Python-related script files on the USBStick (sda1, aka /cdrom). Now that I understand the process, I can always change it back.
After all, this isn't mission-critical, avionics flight software. :)
Here are the applicable modified/created files and their permissions/ownership, which I
maintained vigorously:
-rwxr-xr-x 1 root root 88 Oct 20 22:48 opt/bootlocal.sh
-rwxr-xr-x 1 root root 52 Oct 20 22:39 opt/bootlocal.sh_orig
-rwxr-xr-x 1 dsl staff 189 Oct 20 22:43 home/dsl/filetool.lst
-rwxr-xr-x 1 dsl staff 140 Oct 20 22:36 home/dsl/filetool.lst_orig
-rwxr-xr-x 1 root root 125 Oct 20 22:57 cdrom/MyPython/MyPyBootupScript
-rwxr-xr-x 1 root root 113 Oct 20 23:02 cdrom/MyPython/MyPyBootupScript.py
Here are listings of the files that I created or modified:
=====================================
opt/bootlocal.sh:
#!/bin/bash
# put other system startup command here
/cdrom/MyPython/MyPyBootupScript
=====================================
=====================================
cdrom/MyPython/MyPyBootupScript:
#!/bin/bash
export PYTHONPATH=/opt/python/bin
export PATH="$PATH:$PYTHONPATH"
python /cdrom/MyPython/MyPyBootupScript.py
=====================================
=====================================
cdrom/MyPython/MyPyBootupScript.py:
#!/usr/bin/env python
import time
print '\n\n'
print 'Hello World!!!'
print '\n\n'
time.sleep(5)
=====================================
=====================================
home/dsl/filetool.lst:
#!/bin/bash
# put other system startup command here
opt/ppp
opt/bootlocal.sh
opt/powerdown.sh
home/dsl/filetool.lst
home/dsl/.fluxbox
home/dsl/.xtdesktop
home/dsl/.xinitrc
home/dsl/.xserverrc
home/dsl/filetool.lst_orig
opt/bootlocal.sh_orig
=====================================
Note that I decided to permanently maintain original/unmodified copies of filetool.lst and bootlocal.sh.
You Live, Linux and Learn!
All the best,
Wasgate
original here.