Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Hot answers tagged

187

For running Midori on startup, take a look at this tutorial. For DIY solutions, read on. You can add your script executable command to the bottom of .bashrc that will run your script every time you log in. Make sure you are in the pi folder: $ cd ~ Create a file and write a script to run in the file: $ sudo nano superscript Save and exit: Ctrl+X, Y, ...


42

The way that I've seen most people do it (have a look on the Raspberry Pi forums), and have done myself with success is using /etc/rc.local. All you need to do here is put ./myscript in the rc.local text file. If it's in python, put python myscript.py. This literally is "a simple solution, (like dropping my script in some "startup" directory or something ...


30

Add it to the crontab The crontab runs commands at defined times. Edit the file: sudo crontab -e Add line to file (here a python script): @reboot python3 /home/pi/Desktop/exemple.py &


16

how do I know what version of Python (2 or 3) I'm writing for Well, you should know because it is ultimately your decision! You pick one, you use the syntax of that particular generation, and you invoke the respective interpreter to run your script. If you have both versions installed they can typically be run using either python2 or python3. That's also ...


12

Use udev rules. find your device information. udevadm -a -p /dev/path/device/ KERNELS=="1-3" SUBSYSTEMS=="usb" DRIVERS=="usb" ... ATTRS{quirks}=="0x0" ATTRS{authorized}=="1" ATTRS{manufacturer}=="SANDisk" ATTRS{product}=="USB DISK" ATTRS{serial}=="SD71011000019113" Then create your udev rules file for your device. When creating rules file, use ...


10

You can run any number of scripts with varying programming language. You can think in the direction of using tools like Screen or tmux. They basically are used to run scripts in background or detached mode. This proves to be quite useful when you have a lot of applications you need to keep track of whilst they are running in the background. Installation on ...


10

Assuming that you're not running a weird custom operating system with a minimal kernel, the RPi is running a full fledged version of linux. The applications it comes with are written in C, C++, Java, Perl, Python, and probably others. You'll have to install Julia, but there's no reason the RPi can't handle multiple languages.


9

Autostarting xorg apps If the script you want to start requires an xorg session then you might try following the freedesktop autostart spec which might or might not work depending on which desktop environment you are using. Alternatively, you can target your specific desktop environment as described at https://wiki.archlinux.org/index.php/autostarting. ...


9

use timedatectl - for example sudo timedatectl set-timezone Australia/Sydney


8

First, if the script is run by a system daemon and that daemon is running with root privileges, you do not need to use sudo. This includes init (and systemd), which includes rc.local. If that daemon is not running with root privileges, then sudo will not work unless /etc/sudoers is configured to allow such (and without a password). Raspbian users may be ...


8

I use the following script to backup SD cards on OS X:- #!/bin/bash # script to backup Pi SD card # 2017-06-05 # 2018-11-29 optional name # DSK='disk4' # manual set disk OUTDIR=~/temp/Pi # Find disk with Linux partition (works for Raspbian) # Modified for PINN/NOOBS export DSK=`diskutil list | grep "Linux" | sed 's/.*\(disk[0-9]\).*/\1/' | uniq` if [ $...


7

I want to throw in my two cents, even though this is an old question but commonly asked to do simple thing - autostart. I tried all the suggested solutions in all the answers for this question. NONE of them worked for me. I am using Raspberry PI Model 2 with Raspbian. The only way I could get my application to autostart successfully is through a script as ...


6

I second Shan-Desai's suggestion of tmux, which is great, but perhaps this is actually overkill for your application. If neither of the scripts is in some way interactive, requires user input etc., you can simply run them in parallel with Bash's & operator: $ julia myJuliaScript.jl & python3 myPythonScript.py This will keep the terminal “hanging” ...


5

I also had trouble with this. On the Raspberry Pi3 running Raspbian this is what I did: Create a startup shell script in your root directory (I named mine "launch"): sudo leafpad launch.sh Save the file Edit the LXDE-pi autostart file sudo leafpad /home/pi/.config/lxsession/LXDE-pi/autostart Add this to the bottom of that file ./launch.sh reboot


5

Try starting it this way at the beginning of /etc/rc.local: /full/path/to/myscript.js < /dev/null & & forks it into the background, presuming this is a persistent process. < /dev/null (redirecting standard input to ensure the handle stays open) is probably not necessary, but may make a difference. You need to use the absolute path in rc....


5

In case anyone was interested, I've now been able to make an install script that worked on my current vanilla Raspbian install. Plus, ascii art!: echo $" _________ d b d b d b d b d b ''':::.....:::''' fff .' '. ^ ^.'--. ...


5

Raspian is basically Debian. Debian until and including Wheezy/7 used SysV, since Jessie/8 systemd. Upstart is not relevant anymore, since even RHEL and Ubuntu (the Upstart developers) have moved to systemd. systemd is very different from sysv. However, there is a compatibility layer in systemd that will transparently create units for properly annotated ...


5

I would probably base it on the library I need to use. I would always try to stick with Python 3 as it is the new version, but if a library I need has not been upgraded/converted, then I'll have to use Python 2. Please see here for a list of Python libraries already converted to 3 and those yet to be.


5

You could use "Munin" with Raspbian to monitor your RPis. You need only one "Munin Master" and on each device you want to monitor, the "Munin Node" software. "Munin" is very flexible and comes with numerous plugins. But yet the setup process with Raspbian is fast and simple if you stick to the defaults. For the complete architecture please take a look at ...


5

A script is running without its interpreter when it is made executable and contains a shebang at the very first line. Because your script is running I assume that's the case with your script. But the error message shows that you miss the leading slash in the path to bash. Your shebang should look as follows: #!/bin/bash


4

Use nohup ("no hangup"): nohup myscript.sh </dev/null 1>&2&> nohup.log & The </dev/null provides a standard input stream that won't close, since closing the that may confuse some things. This may or may not be necessary, since man nohup claims that's what it does anyway -- try it without and if that doesn't work, try it with. The ...


4

You do call your script with a path in front, like /home/scripts/test1.sh or ./test1.sh, do you? What does ls -la /home/scripts/test1.sh say?


4

Ok, fixed it with the instructions below. I add this answer because this is quite specific (run when desktop is loaded). open up the file using nano: sudo nano /etc/xdg/lxsession/LXDE/autostart add the following line to the bottom of the file (just as last line) @sh /home/pi/myproject/myscript.sh save and reboot!


4

post-down script; Write a script to call 'reboot' as /path/to/script.sh Edit your /etc/network/interfaces file and add a line just below your eth0 config. auto eth0 iface eth0 inet static name "Ethernet0" address 192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255 network 192.168.1.0 gateway 192.168.1.254 post-down /path/to/script.sh Your /path/to/...


4

Check out PyCharm. I've been a happy paying customer for years, however a free community edition is also available. There is a file watcher plugin that will copy files over to a remote machine (your RPi). And it has the ability to perform remote debugging. wire up debugging modules With respect to setting up PyCharm remote debugging, first thing to do ...


4

You can use dd to backup the drive. The trick is to use the device as the input, not its partitions. Taking an example from the RPi forum, you can backup and even auto compress the information in one action. To backup the device: sudo dd bs=4M if=/dev/rdisk2 | gzip > /Users/`whoami`/image`date +%d%m%y`.gz To restore the device: sudo bash -c 'gzip -dc /...


4

Ok I am giving a shot at this, try following the mentioned steps (type in your Terminal): create a folder called 'lxsession' in your hidden folder called .config: $ mkdir /home/pi/.config/lxsession Depending on your Raspberry Pi Version you can try : $ mkdir /home/pi/.config/lxsession/LXDE-pi/ OR $ mkdir /home/pi/.config/lxsession/LXDE/ now create a ...


4

@SteveRobillard answered my question in the comments. I will re-iterate it here for everyone to see clearly! 1. Viewing running programs: In the terminal type: ps aux | grep programname ps = display currently running processes a = show processes for all users u = display the process' user/owner x = show processes not attached to a ...


4

Here's something which takes a different twist on /etc/os-release, which has a standardized format based around setting shell variables, meaning you can source it and use them. First have a look at the actual file to get the idea, then consider: #!/bin/bash source /etc/os-release case $VERSION_ID in "7") echo "Raspbian 7 is wheezy." ;; "8") ...


4

On Linux systems, there's a special file at /sys/class/net/$interface/carrier (where $interface is your interface name, e.g., eth0, wlan0). You can read from it like you would any other file in Python. If you read a 1, the interface is connected, and if you read a 0, it is not connected. Here's some untested example code to illustrate: def isConnected(...


Only top voted, non community-wiki answers of a minimum length are eligible