Where to store program files?
-
I'm a newbie at the Onion and with Linux, so please bear with me. Where do I store my Python code on the Onion? I've tried writing a simple "helloWorld.py" program using vi, but can't seem to write to a directory. Do I need to compose Python code on my laptop/desktop and then use some mystical tool to write to the Onion?
I also want to install Python-light, so where should this go? Do I control this, or does opkg handle the details?
Jeff
-
It's probably easiest to just copy your program to /root and run it from there. You shouldn't need to worry much about putting it into the system-wide location for programs or building your own package or anything. You will need to specify the path when you run it though -- you'll say "/root/helloWorld.py" (or you can use "./helloWorld.py" if you are currently in /root). You also have to mark it as an executable file before you can run it, e.g. "chmod +x helloWorld.py". (chmod is 'change mode', +x means add execute mode.)
To get your file onto the Omega you should be able to use scp. If your host is Linux or OSX you can just say "scp helloWorld.py root@[onion IP address]:/root/" to copy it there. For Windows I'm not sure but I believe WinSCP is something I've heard of people using.
Finally, you're right about opkg handling the install path for you. If you do "opkg install python-light" it will put all the python bits in the right place with no extra work from you -- just type "python" after the install and it will Just Work
-
As a complement to Jeff's post, be advised that most of the folders are erased during firmware updates, so you run the risk of losing your scripts.
One possible solution is adding the /root folder to the /etc/sysupgrade.conf file, as described in this topic.
Another option would be to use an external USB storage device.
-
Yep, @fader has all the right info. If you're using OS X or Linux, I like to use
rsync
to transfer files back and forth.If you're on the latest Omega firmware, the /root folder should be preserved. (The changes to the sysupgrade.conf file that @Daniel-Sitnik mentioned were added a little while back)