Reg: Auto-Login and run a script Automatically

cancel
Showing results for 
Search instead for 
Did you mean: 

Reg: Auto-Login and run a script Automatically

Jump to solution
16,225 Views
vishvapathi
Contributor V

Hi All,

I would like to have a program starting right after boot. I have made some research about it but I could not find any solution for my problem until now. I want to connect the power supply of my board, it will boot, automatically login, run a script automatically.

Could anyone give me a hint how to automatically run a program?

LeonardoSandovalGonzalez

DaianeAngolini

shanmugamsundar

Labels (2)
1 Solution
1,148 Views
Raybiztech
Contributor V

Hi Vishwapathi,

To make autologin you can use an autologin script located in /usr/bin. This script should contain following data.

#!/bin/sh

exec /bin/login -f usename

You have to change the /etc/inittab getty login line as follows

tty1::respawn:/sbin/getty -L tty1 115200 vt100 # GENERIC_SERIAL //original

tty1::respawn:/sbin/getty -l /usr/bin/autologin -n -L tty1 115200 vt100 # GENERIC_SERIAL

After login init is executing one of the profile script. You can start your application in one of the profile script located in /etc

Thanks and Regards,

RayBizTech.

View solution in original post

6 Replies
1,148 Views
yanggao
Contributor III

Hi all,

 Does anyone know?

Thanks a lot.

0 Kudos
1,148 Views
andy_q
Contributor II

you can modify to ---------->mxc1:12345:respawn:/sbin/getty -l /usr/bin/autologin -n 115200 ttymxc1

0 Kudos
1,148 Views
yanggao
Contributor III

Hi All,

Every time I start my imx6q sabre lite board, it always asks me to enter login: root , so I have tried this way to auto login, in my /usr/bin, I create a autologin script contains this:

#!/bin/sh
exec /bin/login -f root
then in /etc/inittab, I have changed
#mxc1:12345:respawn:/bin/start_getty 115200 ttymxc
to follows
mxc1:12345:respawn:/bin/start_getty -l /usr/bin/autologin -n 115200 ttymxc1

but when I reboot the board, it doesn't auto login, and it display:
INIT: Id "mxc1" respawning too fast: disabled for 5 minutes

I don't know where is wrong and how I should modify this file? I attached my inittab file, thanks in advance!

-------------------------------------------------------------------------------------------

# /etc/inittab: init(8) configuration.
# $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $

# The default runlevel.
id:5:initdefault:

# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
si::sysinit:/etc/init.d/rcS

# What to do in single-user mode.
~~:S:wait:/sbin/sulogin

# /etc/init.d executes the S and K scripts upon change
# of runlevel.
#
# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# Runlevel 6 is reboot.

l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
# Normally not reached, but fallthrough in case of emergency.
z6:6:respawn:/sbin/sulogin
mxc1:12345:respawn:/bin/start_getty 115200 ttymxc1
#mxc1:12345:respawn:/bin/start_getty -l /usr/bin/autologin -n 115200 ttymxc1
# /sbin/getty invocations for the runlevels.
#
# The "id" field MUST be the same as the last
# characters of the device (after "tty").
#
# Format:
# <id>:<runlevels>:<action>:<process>
#

1:12345:respawn:/sbin/getty 38400 tty1

0 Kudos
1,149 Views
Raybiztech
Contributor V

Hi Vishwapathi,

To make autologin you can use an autologin script located in /usr/bin. This script should contain following data.

#!/bin/sh

exec /bin/login -f usename

You have to change the /etc/inittab getty login line as follows

tty1::respawn:/sbin/getty -L tty1 115200 vt100 # GENERIC_SERIAL //original

tty1::respawn:/sbin/getty -l /usr/bin/autologin -n -L tty1 115200 vt100 # GENERIC_SERIAL

After login init is executing one of the profile script. You can start your application in one of the profile script located in /etc

Thanks and Regards,

RayBizTech.

View solution in original post

1,148 Views
vishvapathi
Contributor V

Thanks. It Works

Raybiztech

DaianeAngolini

1,148 Views
daiane_angolini
NXP Employee
NXP Employee

this package adds a script that is executed on startup

https://github.com/Freescale/meta-fsl-demos/tree/master/recipes-fsl/fsl-rc-local

The script itself is empty. But I think you could use this as an example.

0 Kudos