spen_lang
asked on
Running Shell Script after boot on Raspberry PI
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:
I've tried to add
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
Any ideas?
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?
Is "xdotool" in /bin or /usr/bin (or their sbinequivalents)? if not, you need to put the full path to it in the script wherever it is called.
ASKER
xdotool is in /usr/bin/xdotool
I may still try to put the full path to it in the script to see if it works.
I may still try to put the full path to it in the script to see if it works.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sadly - still not working :(
ASKER
You are right though - I'm running the script as pi...
I'm going to add an echo to a file to prove the script both start and finishes... I shall report back.
I'm going to add an echo to a file to prove the script both start and finishes... I shall report back.
Add
exec >/tmp/tstecho.out 2>&1
set -x
to the start of your script, to log every command before it is run, and to capture any errors
exec >/tmp/tstecho.out 2>&1
set -x
to the start of your script, to log every command before it is run, and to capture any errors
ASKER
WOO HOO!! It's working!
You were right earlier saying that I needed to run it as the user pi and n the background...
the reason it didn't work was because I copied your code from here into the pi - and you had typed logon.sh but the script is login.sh
Once I realised - it's working lovely!
Thank you :)
You were right earlier saying that I needed to run it as the user pi and n the background...
the reason it didn't work was because I copied your code from here into the pi - and you had typed logon.sh but the script is login.sh
Once I realised - it's working lovely!
Thank you :)
ASKER
Thank you so much!