1

I need to execute script automatically on boot and display its output on screen but I have two problems.

  • Ubuntu asks login credentials
  • How do I get script display output on screen (to work as in terminal, just simple echo functions).

This all needs work without needing a single button to be pressed.

Questions are:

  1. Is this even possible?
  2. If it is, how?

Thanks for help.

muru
  • 207,228
XperianX
  • 339
  • 1
  • 2
  • 8

1 Answers1

0

You have 2 problems here:

  1. Auto-login to a command line session
  2. Keeping the output of the script after its execution

I think the first problem can be solved like explained here: How to autologin (without entering username and password)(in text mode)

You have multiple options for the second problem.

Option 1: storing the output of the script in a text file, and displaying it at login

In order to do that, you need to redirect the output of the script to a file. You can do that by adding > /path/to/file when you invoke the script.

./yourscript.sh > /tmp/myOutput

Then, you add the following line into your ~/.bashrc file (create it if it does not exist), asking bash to read that file when you login:

cat /tmp/myOutput

The output of the last execution of the startup script should now be displayed each time you log into the system.

Option 2: using tmux (terminal multiplexer)

You can run the execution of the script inside a tmux session, and then, at login time, attach to that session. That way, you'll have the history of the execution.

Tmux is easily installable on Ubuntu with apt-get install tmux

aanc
  • 91