-2

I love raspberry pi and I made many programs in Python. One of them is a cool GPIO robot controlling program. I want to run my pi without any display. I also want my pi to run that specific program when it is powered on.

Is that possible.

soundslikeodd
  • 1,078
  • 3
  • 19
  • 32
  • Yes, of course it's possible. What OS are you running on your Raspberry PI? That info is needed to provide a relevant answer. – DavidO Jan 01 '17 at 03:25
  • @DavidO I am using Raspbian os as default – Jayesh Padhiar Jan 01 '17 at 03:27
  • 1
    http://raspberrypi.stackexchange.com/q/8734 – DavidO Jan 01 '17 at 03:28
  • Thanks DavidO this was very helpful. – Jayesh Padhiar Jan 01 '17 at 03:34
  • Possible duplicate of [Start shell script on Raspberry Pi startup](http://stackoverflow.com/questions/30507243/start-shell-script-on-raspberry-pi-startup) – filleszq Jan 01 '17 at 03:48
  • @DavidO OK Thanks, but how can I get my pi back to Raspbian Os ? – Jayesh Padhiar Jan 01 '17 at 04:38
  • I don't think that you changed operating systems, so you must be asking how to regain desktop/shell login control on a system that is booting to some script. If you have the PI set up to receive SSH logins, you can login over SSH and undo the changes you made to boot to a script. If you don't have SSH login on the PI, you could remove the SD card, put it into your computer or a card reader, mount it, and manipulate it to undo the changes you had previously made. – DavidO Jan 01 '17 at 12:55

2 Answers2

0

You will need to launch the script at startup. This is really a linux question, and there are many ways to accomplish this. Here are two:

  1. Launch Python from crontab
  2. Launch script at startup
Community
  • 1
  • 1
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
0

For running python script at startup , you can either

edit your etc/rc.local You could make your /etc/rc.local look like this:

   /yourpath/bin/yourscript.sh &

Then in yourscript.sh put:
    #!/bin/sh
    sleep 10
    sudo python scriptname.py

OR

you can use crontab which makes it easier to start the python script at reboot or at a specific time as 11pm everyday like that.

I have done by this reference https://www.dexterindustries.com/howto/auto-run-python-programs-on-the-raspberry-pi/

Vivek V C
  • 7
  • 5