0

Can anyone please help me to run a simple python script at start up? (for eg. let the script print hello) please explain me step by step,,,starting from basic steps!

I tried many examples using init.d & rc.local but not worked... may be I had gone wrong! so be precise,clear,step by step starting from basic step!

8
  • 2
    Given that you have tried many examples it seems unlikely that a new example will help you. Why not show us the closest to working example you have tried?
    – joan
    Commented Feb 20, 2015 at 11:41
  • @joan: friend,,, I have asked this question since i tried many methods even the link u have mentioned...but not working! May be I have wrong with the steps and thats why I have asked for a step by step answer. so please help me with the question posted!
    – sachin
    Commented Feb 20, 2015 at 12:05
  • 1
    Please provide more information on what you tried. Also try finding log output(or create it yourself) and provide this too.
    – Izzy
    Commented Feb 20, 2015 at 12:17
  • @MKzero : I want to run a script which prints "hello" at sartup/boot. so i kept this script file in /home/pi as hello.py and used sudo nano rc.local to edit rc.local and added location as follows; /usr/bin/python3 /home/pi/hello.py just before exit o & saved it. But at start up it gives the error either as invalid syntax or exit: illegal number o!
    – sachin
    Commented Feb 20, 2015 at 12:40
  • Can we see the python code (add it to your question)? and does the script run from the command prompt (e.g. python3 hello.py)? Commented Feb 20, 2015 at 12:49

1 Answer 1

0
sudo bash

create a file in /etc/init.d name it like vncboot.sh

sudo nano /etc/init.d/vncboot.sh

then

chmod 755 /etc/init.d/vncboot

then

update-rc.d /etc/init.d/vncboot defaults

if it says

update-rc.d: error: unable to read /etc/init.d//etc/init.d/vncboot

use

update-rc.d vncboot defaults

source: http://elinux.org/RPi_VNC_Server#Instructions | section: run at boot

3
  • Beware that there are pretty strict rules about the format of that .sh file, see /etc/init.d/README. This is the more complicated way to go and not really necessary if you just want something to run once at boot.
    – goldilocks
    Commented Feb 20, 2015 at 13:22
  • sorry @user3599188 i have no knowledge regarding 'vnc' and moreover dont want to use and hope there is still a simple way for doing this process.
    – sachin
    Commented Feb 20, 2015 at 14:56
  • waiting for a favourable reply!
    – sachin
    Commented Feb 23, 2015 at 9:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.