Hello, I was wondering if you knew a way to automatically start basic_test_all.py on boot? I can run the script just fine by using ssh and another computer on the network or by plugging a monitor and keyboard into the pi itself. However I really just want the pi to start, the script to run automatically, and I can press the keys to move the robot around.
Hi,
Just wanted to check a few things, are you using a wireless keyboard to control the GoPiGo after setup because the cronjob would be running on the main terminal after boot.
Also, would it be possible for you to connect the Pi to a monitor and check why the script is failing.
I am using a wireless keyboard connected to the GoPiGo. I used the keys specified in the file to try to move it after it boot. I have tried it with a monitor connected directly to the pi. However, I don’t see a terminal pop up on boot, and pressing the keys doesn’t move the GoPiGo.
The chron log shows that EOF error. However, if I try to run the launcher.sh file manually by going to its location and typing “sh launcher.sh” it does start the program, and I can use the keys to move it. So I know my launcher is working, the given python program is working, but it doesn’t start automatically with the chron job and instead has the EOF error in the log.
Hi,
I think that the problem might be with the way you running the script. At startup there are other things there are also programs being run one by one so maybe the python Program try to block their execution because it’s waiting for the input and the OS terminates the program. I am not sure about this but it does look like the problem is related to getting the user input on runtime.
Thanks for all your help and for the thread. After reading that forum, it is working!
First, I decided to use basic_robot.py and I moved it to my desktop.
Then I did the following:
mkdir ~/.config/autostart
nano ~/.config/autostart/myprogram.desktop
I entered this in nano and saved:
[Desktop Entry]
Exec=lxterminal -e "sudo python /home/pi/Desktop/basic_robot.py"
Type=Application
I also made the given Python program executable by: chmod +x basic_robot.py Then I checked that the python program had the #!/usr/bin/python at the top of its program and it already did.
I rebooted and now it starts the program in terminal. I can press a key and the enter key for it to move without having a monitor attached or using ssh from another computer.
Hi,
Great to hear that it’s working and thanks a lot for letting us know how to get it to work. Hopefully this will help someone else too in the future.
Dear Karan,
I am also having the same kind of problem.Stared using pi few days back.
following is my code located at /home/pi
#!/usr/bin/python
name = raw_input()
print name
thats all.
In above example I could not see the reference myprogram.desktop anywhere.
In what way I can make above example executable 5 seconds after boot ?
In attached link /yourpath/bin/yourscript.sh & is mentioned. Does yourpath means make something new having /bin directory & then .sh in that ?
Your help will give me a boost.
Thanks
vpmax
So what worked for @rosetyler was that she made a .desktop file which had a link to the python file and placed the desktop file in the autostart folder.
Dear Karan ,
Thanks for your quick reply. I will try to understand the mechanism related to this. One more thing I will never be using windows part of it I mean GUI (Is it desktop refered above ?) Will it still work for me ? I will be using command prompt of things . It shows ~$. Thanks again. I will let you know . It may take little more time for me to understand whole thing.
Thanks again
Hi,
I think it should work, because it is automatically loaded on startup. I have not tried this but it worked for @rosetyler without SSH or using a desktop. I think what is does is the after the boot sequence getting completed and the desktop loads, it automatically starts the script and whatever you enter via the keyboard is automatically taken by the script. You might have to set the Pi to boot to desktop.
This a pretty clever hack nad I can’t think of a better way to do it.
I tried hard with many ways but no success yet. I tried to move .desktop file in .Desktop folder but could not run.
I will start all again may be some thing missing as there are no errors or warnings.
Thanks
When it works I will let you know.
Hi, Do let us know if you are able to get it to work and the Raspberry Pi forums would be a good place to start looking around for answers and asking questions.
I have to add usr/bin/lxterminal in the path though it is in the first line of the program. Whole program is working now . Procedure mentioned above is correct.
Thanks Karan for your help and encouragement.
vpmax
My daughter is attempting to use the method above to autostart a Scratch project on her GoPiGo 2. We are successfully getting Scratch to start upon boot, but it requires a mouse to click Start Programming and then on “OK” on the alert that follows. Is there a way to either bypass those or include that input in the .desktop?
@RobertLucian, thank you! That worked for her with one very minor tweak. The f in Raspbian_for_Robots is actually capitalized on her instance. So it is actually Raspbian_For_Robots. Thanks again for a quick response to my question.