1

I am trying to display a message when I log on to Linux Mint 17.2. I have tried various methods without success:

1) I created a file /home/myusername/Desktop/startup-message.sh as follows:

#!/bin/bash
echo "My startup message"
pause
exit

I made the file executable and made sure it works from a command line, e.g.

bash "/home/myusername/Desktop/startup-message.sh"

or

sh -c "/home/myusername/Desktop/startup-message.sh"

Then I used Mint's 'Startup Application' feature and added a new entry. I tried:

  "/home/myusername/Desktop/startup-message.sh"
  bash "/home/myusername/Desktop/startup-message.sh"
  sh -c "/home/myusername/Desktop/startup-message.sh"

with and without quotes around the path name. In all cases, nothing was displayed and the "pause" was ignored.

Finally, I added a command to copy a file after the pause, and the file was copied. So, it appears that echo and pause are ignored in a start-up file, presumably because no terminal is open?

2) I then tried adding the message to /etc/profile, but the message didn't appear when I logged on.

3) I then tried adding the message to /etc/motd, but the message didn't appear when I logged on.

So how can I perform this simple task?

  • Are you logging into a terminal or X? – eyoung100 Aug 9 '15 at 22:43
1

You are confusing the function of echo. echo will print to the standard output file descriptor. If you already have a terminal open, that terminal is usually the standard output of the commands/scripts you run within it. By itself, echo will not open a terminal.

If you want to display a message on startup, a more "graphical" way would be to use something like zenity:

zenity --info --text "Hello, world!"

If you put that in your startup script, you will see a message box displayed to that effect.

Also, motd prints your message for text-based logins (like a login on a virtual terminal or a login via ssh) so it's not going to do what you want either.

If you want to specifically open a terminal on startup, you can make your script do something like:

xterm -e 'bash -c "echo My startup message;sleep 10"'
  • Thank you. The "zenity" command does exactly what I need. – cdgoldin Aug 9 '15 at 23:38
0

Why not just add this echo into ~/.bashrc or ~/.bash_profile ?

More info at An Explanation of .bashrc and .bash_profile

Both the ~/.bashrc and ~/.bash_profile are scripts that might be executed when bash is invoked. The ~/.bashrc file gets executed when you run bash using an interactive shell that is not a login shell. The ~/.bash_profile only gets executed during a login shell.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.