LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to automatic run a shell script at boot? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-automatic-run-a-shell-script-at-boot-675041/)

trickykid 10-08-2008 04:13 PM

I don't know about KDE but under Gnome, you should have a Sessions in System > Preferences > Personal > Sessions

This is where you can add startup programs. I'm sure KDE has the same options, just couldn't tell you exactly the path to configure programs to startup within KDE at login.

But you can add all you want to your bash initialization scripts, it's not going to work since you're not logging into a console and you're using a plain old bash script. It needs to be run in a terminal to work. ;)

ceantuco 10-08-2008 04:27 PM

thanks Trickykid! I'll try it later! I appreciate your help!

David the H. 10-08-2008 10:25 PM

Have you made sure you have proper execute permissions on the script as well? Perhaps you should tell us in more detail exactly what you've tried, i.e. what lines you've tried addding to the files and whatnot.

And pay attention to trickykid's comment about the script itself needing a gui. If the thing only runs in a terminal, then you're not going to see anything because it doesn't know how to open up a terminal window on startup so that it can ask you for input. You either have to use something like xdialog, kdialog, or gtkdialog in your script in order to get a window, or perhaps start it from a shortcut with the "run in terminal" option selected.

~/.kde/Autostart (or the equivalent in gnome) really should work, provided you have everything else working right. You could also keep the script somewhere else and create a shortcut to it in that directory.

David1357 10-09-2008 07:35 AM

Quote:

Originally Posted by trickykid (Post 3304506)
It still won't work unless this script is either a GUI program or it's launched within a terminal like I've pointed out.

That is not true. I tried it on an Ubuntu machine, and the commands in my "~/.profile" got executed when I logged in via the GUI.

Now if the script is doing something like "read", then you are right about needing to launch a terminal. However, I have been operating under the assumption that the script asked the question using a dialog.

ceantuco 10-09-2008 11:37 AM

Hi David,

I ran chmod 755 [file] to give the proper permissions to my script and I'm able to run it when I type my file name and then hit enter. I just can't get the damm thing to run when I log in! This is very frustrating.

David the H. 10-09-2008 12:01 PM

Quote:

Originally Posted by David1357 (Post 3305145)
However, I have been operating under the assumption that the script asked the question using a dialog.

I wouldn't assume that. ceantuco's description said it prompted the user for input, but didn't make it clear exactly how it does that. Since he called it his "first script", the reasonable assumption is that he's using a simple read prompt. If he hasn't arranged for either a terminal window or a gui dialog to pop up, then the script is certainly being executed, but hanging or failing because there's no way to give it the input it needs.

Of course a good way to test if it's actually getting executed is to add a few debugging lines and then check if anything new has been logged after login.

David the H. 10-09-2008 12:08 PM

ceantuco, how exactly does the script prompt you? Are you using any kind of gui dialog, or just the terminal prompt? Perhaps you could post it here for us?


All times are GMT -5. The time now is 02:46 AM.