Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
Pages: (3) </ [1] 2 3 >/

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: How Do I Run Python Scripts At DSL USBStick Bootup, DSL 0.8.2 & Python.uci & USB Stick< Next Oldest | Next Newest >
wasgate Offline





Group: Members
Posts: 7
Joined: Nov. 2003
Posted: Oct. 19 2004,14:53 QUOTE

Hi folks!

I now have DSL 0.8.2 booting up from a PNY 256MB USB 2.0 USBStick/KeyDrive/PenDrive/ThumbDrive (/dev/sda1), including python.uci.

Now, how do I run one, or more, of my own Python scripts, stored on the USB Stick, automatically, at bootup?

I've located Python in /opt/python/bin, and I suspect that there is some command that will allow me to execute/run Python from any other directory path.

In another post, I found the following, which might be related:

export PYTHONPATH=/opt/python/bin
export PATH="$PATH:$PYTHONPATH"

Am I on the right track?  Where (which file) do I modify with these two lines, or whatever else that is needed?

Also, what file needs to be modified so that my Python script(s) are executed automatically at bootup?

BTW, I wasn't able to 'multi-partition' the PNY 256MB USB Stick into sda1 & sda2 (The PNY FAQ webpage said that it wasn't possible).  I probably was just doing something wrong.  I'll leave it for another day.

Thanks for all the informative posts, past & future!

Wasgate
Back to top
Profile PM 
jls legalize Offline





Group: Members
Posts: 476
Joined: April 2004
Posted: Oct. 19 2004,19:58 QUOTE

maybe your scripts could be useful 4 other people?
Back to top
Profile PM WEB ICQ MSN YIM 
ke4nt1 Offline





Group: Members
Posts: 2329
Joined: Oct. 2003
Posted: Oct. 19 2004,20:16 QUOTE

Yep,
What you found will help you get to where you want to be.

e.g.

You want "myfav.py" to run at boottime .

make a script like this..

#!/bin/bash
export PYTHONPATH=/opt/python/bin
export PATH="$PATH:$PYTHONPATH"
python /home/dsl/myfav.py

Save the script under a name like " start_myfav "
Add a line for the start_myfav script to your /opt/bootlocal.sh file .. This will autorun it at boottime
e.g   /home/dsl/start_myfav

You will need to place copies of BOTH myfav.py AND start_myfav
in a path location, like /home/dsl/ , as I did in the scripts ..
If you place them anywhere else, edit your entries accordingly.

Then you need to add both files to your /home/dsl/filetool.lst ,
so your backup picks them up..

home/dsl/myfav.py
home/dsl/start_myfav

Now, create a backup , either thru the dslpanel or the menu.

Then reboot, ... when you reach the boot: prompt
add the line " restore=sda1 "  to your bootup commands ..
( or restore=??  wherever you made your backup write to )

The system will restore the backup, and run the bootlocal.sh ..
The bootlocal.sh will find and execute the start_myfav script ..
The start_myfav will find and execute the myfav.py in a python env.

73
ke4nt
Back to top
Profile PM 
wasgate Offline





Group: Members
Posts: 7
Joined: Nov. 2003
Posted: Oct. 20 2004,01:32 QUOTE

Thanks, ke4nt/Kent, for the thorough reply.

I've had some success, but ran into a problem with the backup.tar.gz creation process.

First though, I want to mention that I decided to keep the 'start_myfav' bash script and my Python script(s) on the keydrive (sda1), so that I wouldn't have to modify filetool.sh for their sake.

Next, even though /dev/sda1 is automatically mounted as /cdrom, I added 'mount -t vfat /dev/sda1 /mnt/sda1' to bootlocal.sh.  The next line after this was '/mnt/sda1/MyPython/start_myfav' to execute the 'start_myfav' bash script (/mnt/sda1/MyPython is where I'm keeping the bash script and Python scripts).

The advantage to keeping the bash script 'start_myfav' and my Python script(s) on the sda1 keydrive, in my mind, is so that I won't have to modify filetool.lst on their behalf (bootlocal.sh is already in the list of backed up file, in filetool.lst).

I then attempted to do a backup (to backup the change to 'bootlocal.sh'), but had a bit of trouble figuring out what to type into the filetool 'Device:' input field.  I finally settled on 'sda1' which eventually created 'backup.tar.gz' on the root of sda1.  So far so good.

I then rebooted, and used 'dsl restore=sda1 mydsl=sda1' at the 'boot:' prompt.

Once booted, I verified that bootlocal.sh executed by checking that /dev/sda1 got mounted to /mnt/sda1, which it had.  However, the line '/mnt/sda1/MyPython/start_myfav' apparently didn't get executed, as my Python script didn't start up.

So, I started tweaking this particular line to try to get it to work.  I'd make a change to bootlocal.sh and then do a backup, prior to rebooting.  I did this once, and for some reason decided to manually delete backup.tar.gz on sda1, just prior to doing another backup, after modifying bootlocal.sh.

Then, the problem cropped up.  I'd attempt to do the backup, using either the DSLPanel or DSLMenu, but it wouldn't create backup.tar.gz on sda1.

Since I was starting to get tired, I decided to call it quits and post this progress report post.  I hope it's written well enough to get the idea of the problem across, as I'm still tired!

I'll return to the problem tomorrow, with a fresh mind.  I'll get it figured out.

Thanks again for the detailed info.

Wasgate


--------------
Wasgate
======================================================
Zu leben ist ein Bier und ein Linux!  Eins, zwei G'Suffa!
======================================================
Back to top
Profile PM 
henk1955 Offline





Group: Members
Posts: 249
Joined: June 2004
Posted: Oct. 20 2004,07:14 QUOTE

if you boot from /dev/sda1.
then /dev/sda1 is mounted as /cdrom.
dot NOT EVER mount /dev/sda1 again to /mnt/sda1
the problem is that at backup time the filetool.sh tries to find the sda1 in the mtab file. it will find 2 entries for /dev/sda1.
therefore the backup will fail.

if you want your python script to run use:
/cdrom/MyPython/start_myfav
and not
/mnt/sda1/MyPython/start_myfav


--------------
You have a Q or just want to chat?
Come to #damnsmalllinux on irc.freenode.net!
Open 24/7

dell latitude c640 p4@1.6Ghz 256Mb DSL0.9.1-remaster
asus p4p800-vm p4@2.8Ghz HT / celeron@2.4Ghz 512Mb DSL0.9.1-remaster (alsadebs.dsl)
ABit BE6 celeron@466 256Mb DSL0.9.1-remaster (xawtv)
Back to top
Profile PM WEB MSN 
10 replies since Oct. 19 2004,14:53 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

Pages: (3) </ [1] 2 3 >/
reply to topic new topic new poll
Quick Reply: How Do I Run Python Scripts At DSL USBStick Bootup

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code