Bronto
Posts: 17
Joined: Fri Apr 19, 2013 3:30 pm

Auto login and start a script

Sun Nov 03, 2013 6:45 pm

Hi all,

I am able to run a script, called hello.py without the need for a monitor as it boots into command prompt. So, using a keyboard I log in, And then type ./hello.py

Here's what I do:

Login PI
Password raspberry


Then I wait about ten seconds for the raspberrypi$ to appear then I type ./hello.py


So, my question is how can I do all this automatically, so I don't need to use a keyboard?

I want to auto login, then when the command prompt appears, type ./hello.py

Thanks in advance

Bronto

Takenover83
Posts: 166
Joined: Mon Sep 02, 2013 5:39 am

Re: Auto login and start a script

Sun Nov 03, 2013 6:48 pm

First do this to setup your auto login.
http://elinux.org/RPi_Debian_Auto_Login

Then edit .bashrc. Just add your command to the bottom. It will be run after login.

Code: Select all

nano ~/.bashrc

Bronto
Posts: 17
Joined: Fri Apr 19, 2013 3:30 pm

Re: Auto login and start a script

Mon Nov 04, 2013 12:02 am

Thanks for that.

So here's where I'm at:

Made all the changes as instructed and after reboot the script which is supposed to play an audio file, doesn't.

So, I remote connected into it. Then, I simply double clicked on lax terminal and the script started to play straight away.

So, the way I need it to work is that it will log in and open that file automatically without the need for me to remote in.

Thanks for the help

User avatar
Hove
Posts: 1205
Joined: Sun Oct 21, 2012 6:55 pm
Location: Cotswolds, UK
Contact: Website

Re: Auto login and start a script

Mon Nov 04, 2013 9:15 am

If you want it to run without a user logging in, you could add an init.d boot time script:

I used this as my starting point and tweaked it to use my python script instead - the changes to use your bash script will be similar.

http://www.stuffaboutcode.com/2012/06/r ... rt-up.html
www.pistuffing.co.uk - Raspberry Pi and other stuffing!

Bronto
Posts: 17
Joined: Fri Apr 19, 2013 3:30 pm

Re: Auto login and start a script

Tue Nov 05, 2013 10:46 pm

The problem here though is it just doesn't run the script for me. You see if the script runs successfully it will play an audio file.

However, connecting it to a monitor it is logged into the desktop. So, I double click on the terminal and the script starts automatically. I don't end to type in ./hello.py or anything it just starts.

I just want this to happen from the get go, without me needing to log in and do anything other than turn it on.

MrCartas
Posts: 12
Joined: Tue Sep 24, 2013 6:03 pm

Re: Auto login and start a script

Wed Nov 06, 2013 11:36 pm

Check this link. It's exactly what you want to do: http://raspberrywebserver.com/serveradm ... rt-up.html

malyon2001
Posts: 1
Joined: Fri Jan 03, 2014 6:21 pm

Re: Auto login and start a script

Fri Jan 03, 2014 6:24 pm

This seems to have bricked my pi. On startup it now says

Cannot open /Dev/ttyl: no such file
Re spawning too fast: disabled for 5 minutes

How do I now unlock my pi again? I can't get to the start options to login.

wangdino
Posts: 1
Joined: Sun Jan 26, 2014 5:11 am

Re: Auto login and start a script

Thu Jan 30, 2014 3:20 am

This seems to have bricked my pi. On startup it now says

Cannot open /Dev/ttyl: no such file
Re spawning too fast: disabled for 5 minutes

How do I now unlock my pi again? I can't get to the start options to login.
I guess it should be tty1 (number 1 instead of letter l), plus it should be /dev instead of /Dev

Anyway you can't literally "brick" your RPi because you always have the SD card. You can mount it somewhere else and try to re-modify the files or you can simply dd a fresh image into it.

Rapheal2k14
Posts: 1
Joined: Thu Feb 20, 2014 1:31 pm

Re: Auto login and start a script

Thu Feb 20, 2014 1:37 pm

Hello Everyone,
I am trying to run a python script on autostart but the script has dependencies. I tried editing rc.local with the script path but how do I add the path for the other dependencies so it works correctly.

Thanks a lot.
Raph

marlosdamasceno
Posts: 2
Joined: Tue Oct 06, 2015 4:03 am

Re: Auto login and start a script

Sun Oct 25, 2015 9:52 pm

Hi Bronto,

I think that you are looking for this http://www.opentechguides.com/how-to/ar ... start.html

Best regards

Lefteris
Posts: 2
Joined: Sat Feb 14, 2015 3:46 pm

Re: Auto login and start a script

Thu Mar 03, 2016 5:52 pm

Hello, what is the way for autologin in console . For CLI not GUI. I want autologin to different user than "pi" in command line console.
The file "/etc/inittab" is missing.

Return to “Raspbian”