Running Shell Script after boot on Raspberry PI
bash, linux, raspberry-pi, raspbian, shell
Solution
The reason it wasn't working was because the script needed to be run as the user pi.
I changed the code in the rc.local script to this: `su - pi -c "bash /home/pi/logon.sh &"`
This makes the script run as the user pi and the ampersand is used to make the script run separate to the rc.local script by forking it. (http://hacktux.com/bash/ampersand)
Problem
I'm making a web kiosk display board using a raspberry pi and I want to send some key strokes to the browser window 2 minutes after it's loaded. The script sends the logon details for a webserver. I've got a script that sends the keystrokes which works fine from the telnet console: ``` #!/usr/bash username="username" password="password" echo "Setting Display" export DISPLAY=:0 echo "Sending Username" for char in $(sed -E s/'(.)'/'\1 '/g <<<"$username"); do xdotool key $char done xdotool key Tab echo "Sending Password" for char in $(sed -E s/'(.)'/'\1 '/g <<<"$password"); do xdotool key $char done xdotool key Return echo "Waiting 5 Seconds" sleep 5 echo "Setting Remember Password" xdotool key Tab xdotool key Tab xdotool key Return echo "Finished" ``` I've tried to add `bash /home/pi/logon.sh` to the rc.local file - but it doesn't send the keystrokes to the browser? Does any one know why that would be? As I say - it works fine from the telnet window if I run the script, but it doesn't work when run from boot. I had `sleep 120` on the line before it to stop if firing right away and wait until the browser has loaded - and I know the script is running from rc.local, because when I remove the sleep command, I see the echos from the script. Any ideas?