Drop to shell AND immediately run a program -- possible?

I am using OpenWRT on a device with a local monitor.
May anyone point me please to a tutorial or give an advice how can I force to boot OpenWRT machine directly to shell?
In my case the welcome screen appears only if I press any key on the keyboard.

My main goal is to drop to shell and hopefully run a program automatically.

If I try to add the command to start my program ( "/root/my_program" ) in the respective LUCI web- interface section, nothing happens. When I log-in and start the program manually it runs perfect.


  1. I need to have a keyboard attached to push any button so the shell appears,
  2. I need the same keyboard to press "/root/my_program" to start it

Thank you very much in advance!

and which section is that, exactly ?

The boot (and shutdown) sequence is controlled from the "/etc/inittab" configuration file. The login prompt that you see on the console belongs to the "askconsole" entry, and is executed from the "/usr/libexec/login.sh" script.


Just here:
But I am looking now more for editing the /etc/inittab

Thank you!
This is where I am now. I found this files and tried to play with them. Please kindly see what I have done, I have changed /etc/inittab and now it is like this:

::sysinit:/etc/init.d/rcS S boot
::shutdown:/etc/init.d/rcS K shutdown

But now the shell not appearing at all :slight_smile:
May you please point on my mistake?

(Maybe I can put my program here, by the way?)

I have also played with the /usr/libexec/login.sh Please have a look and point kindly where should I put my program:


[ "$(uci -q get system.@system[0].ttylogin)" = 1 ] || exec /bin/ash --login

exec /bin/login

Thank you

Some more results. I have made a script at /root/run.sh which can start my program and modified the /etc/inittab. I deleted the lines:


and added this lines:


Wow! Now my program runs after I hit Enter. Not showing the shell, which is good.
But maybe someone could please point me to a fine tuning of this askconsole and askfirst methods, so my program (script) will start right after boot without need to hit Enter? I guess, there should be some alternative to them?

Thank you!

1 Like
sed -i -e "/^tty1:/{s|askfirst|respawn|;s|/.*$|/root/run.sh|}" /etc/inittab


If you just want a program to run once automatically upon boot, call it from /etc/rc.local. Since it won't be running in the login tty, you won't see its output on the attached monitor, but you can use calls to logger or wall to make it visible.

If you have a program that you want to start up upon boot and keep running, write a service controller for it in /etc/init.d. Use one of the existing services as an example.


Yes, I want it to run on the screen,
Seems I found the best solution, while still have to press ENTER

Unfortunately nobody here could help me to fine tune this lines in the /etc/inittab:




will load automatically.

Thank you,
As soon as you did not posted any human-readable sentence, I believe you understood the question and gave the best reply.
I will give it a try.

1 Like