Unix & Linux Asked by Hexodus on December 9, 2020
I have created a simple bash script called echo.sh. Which outputs a string. I’ve made sure its executable. And i then added it to the “startup applications” program through the GUI interface. However when i reboot my machine, it doesn’t appear to of been executed, as there is no echo appearing in a terminal.
from my understanding shouldn’t the script ,when executed, open up a terminal automatically from my understanding because of the STDOUT being the terminal file. However the script works fine if i launch it myself from the terminal.
#!/bin/bash echo "hello this is a bash script talking"
Making it Executable
chmod +x echo.sh
Adding to “startup applications with correct directory to file”
However when i reboot the system, the script doesn’t run as expected, and no terminal appears with the echo message. I’m unsure as to why, and i may be completely missing the point, if so please let me know.
just to note, all my other bash scripts work , such as my “cleanup.sh” script which is also in the “startup applications” program.
I’ve tried redirecting the STDOUT to the terminal file /dev/tty. However this doesn’t seem to work.
#!/bin/bash echo "hello this is a bash script talking" >/dev/tty
I’ve also tested a bash script with just a simple rm command, just to check if it was just the echo command that was having a problem. However when added to start up applications or .bashrc file, it doesn’t delete the test.txt in the same directory as the script. However works when i execute manually from the terminal.
#!/bin/bash rm ./test.txt
I’ve also tested startup applications program itself with just opening Firefox, with just the command Firefox. Which works without an issue. So their doesn’t seem to be an issue with the startup applications program itself?
The simples method use the crontab like so;
Add your script at the of the contrab file
# @reboot /path-to-your-script/your-script-name.sh
Then reboot to observe the change
Answered by Dohd on December 9, 2020
You can check the config file of the autostart file you created with
If you want to execute your script in a terminal you should add
to the file.
You can also set
Hidden=false accordingly to what you want to achieve.
Answered by MatthiasRoelandts on December 9, 2020
The script probably works, but the STDOUT of the script (wherever the output is directed to) is connected to the process on your OS that is concerned with launching startup scripts like this, which does not run in a terminal, but is a user hidden process within for example the kernel. To open up a terminal with this message you should probably edit it to
#!/bin/bash gnome-terminal -e 'echo "hello this is a bash script talking"'
(I'm not on Ubuntu right now so can't test this, but the gist is to explicitly open a terminal where you want this message to show up in)
Answered by rien333 on December 9, 2020
1 Asked on January 9, 2021 by ariana-williams
0 Asked on January 9, 2021
1 Asked on January 9, 2021 by fenil-shah
4 Asked on January 8, 2021
1 Asked on January 8, 2021 by pieterkeesdejong
3 Asked on January 8, 2021 by user2039379
2 Asked on January 7, 2021 by brykkan
1 Asked on January 7, 2021 by amacnewbie
0 Asked on January 7, 2021 by nicholas-dipiazza
0 Asked on January 6, 2021 by vedant-nandwana
10 Asked on January 6, 2021 by ravnoor-s-gill
5 Asked on January 6, 2021 by l0b0
12 Asked on January 5, 2021 by luigi-tiburzi
1 Asked on January 5, 2021 by cw-holeman-ii
1 Asked on January 5, 2021 by lus-gustavo-monezi
2 Asked on January 5, 2021 by ben-flowers
3 Asked on January 5, 2021 by preet
1 Asked on January 5, 2021 by mike-dank
4 Asked on January 5, 2021
3 Asked on January 4, 2021 by wariobrega
Get help from others!
© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP