ahsanraza
Posts: 14
Joined: Tue Mar 31, 2015 4:43 pm

Autorun the Bash file when I power Raspberry Pi

Wed Dec 09, 2015 12:11 pm

Hi forum!
I am using Raspberry Pi B+ and Raspbian Jessie (2015-11-21). I want to place my pi at a table and just power my pi to run the bash file. nothing should be connected with pi like Mouse, Keyboard, LAN cable etc. Just the power supply and Pi should run my file. Like the other real time devices (Arduino). I have tried different methods but it didn't work. can anyone help me?
Tell me and I forget. Teach me and I remember. Involve me and I learn.

flubbard
Posts: 65
Joined: Tue Dec 08, 2015 12:41 pm
Location: Ohio, USA
Contact: Website

Re: Autorun the Bash file when I power Raspberry Pi

Wed Dec 09, 2015 9:59 pm

I'm not sure what you've tried before. Have you tried adding your script to

Code: Select all

/etc/rc.local
something to the effect of a line that reads

Code: Select all

sudo /path/to/my/script.sh
I would make sure that the script is executable and verify that it runs from the terminal first.

- Barry

User avatar
expandables
Posts: 654
Joined: Fri Jun 27, 2014 7:34 pm
Location: Neverland with Michael Jackson

Re: Autorun the Bash file when I power Raspberry Pi

Wed Dec 09, 2015 10:08 pm

Put your script in

Code: Select all

.bashrc
and bingo you won.
:twisted:
By thinking like an engineer you can create a raspberry pi.
Michael Jackson enthusiast.
I got the PI model B, B+ and PI 2 model B.
When will I get the A? I don't know.

User avatar
kusti8
Posts: 3439
Joined: Sat Dec 21, 2013 5:29 pm
Location: USA

Re: Autorun the Bash file when I power Raspberry Pi

Wed Dec 09, 2015 10:30 pm

expandables wrote:Put your script in

Code: Select all

.bashrc
and bingo you won.
:twisted:
That only runs when you log in and then you ha e to enable autologin for it to work and it will run every login. The best solution is crontab or rc.local.
There are 10 types of people: those who understand binary and those who don't.

Return to “Beginners”