LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Open a Terminal and run a program after Gnome boot. (https://www.linuxquestions.org/questions/linux-newbie-8/open-a-terminal-and-run-a-program-after-gnome-boot-515690/)

sirius56 01-02-2007 03:29 PM

Open a Terminal and run a program after Gnome boot.
 
After FC6 boots, I would like to open a Terminal window on the GUI desktop and then run a text application in that window.


I can open a terminal window by placing an xterm command into Startup:

System > Prefs > More Prefs > Sessions > Startup > add xterm
That works. (There are probably more elegant ways to do this)

Then I should be able to follow xterm by the program I want.

Suppose I want to run "cal" after the terminal is opened. Then I might use the following command in Startup:

xterm && cal

or xterm && ./usr/bin/cal

However, the above two lines don't work for me in Startup.

Any thoughts on how to automatically start a program in the opened Terminal window?

Thank you.

btmiller 01-02-2007 03:56 PM

Check out the -e argument to xterm, i.e. do "xterm -e myprogram". You can find more details in "man xterm".

jonnycando 01-02-2007 04:36 PM

Quote:

Originally Posted by sirius56
After FC6 boots, I would like to open a Terminal window on the GUI desktop and then run a text application in that window.


I can open a terminal window by placing an xterm command into Startup:

System > Prefs > More Prefs > Sessions > Startup > add xterm
That works. (There are probably more elegant ways to do this)

Then I should be able to follow xterm by the program I want.

Suppose I want to run "cal" after the terminal is opened. Then I might use the following command in Startup:

xterm && cal

or xterm && ./usr/bin/cal

However, the above two lines don't work for me in Startup.

Any thoughts on how to automatically start a program in the opened Terminal window?

Thank you.

I work in terminal windows all the time from within Gnome. Seeing how I cut my teeth on the command line, it's no biggy for me after all. I have an icon on my desktop to open; Xterm, Xterm with root privileges, or I can right click on the Gnome desktop background, and the context menu which opens will have an "open terminal" command. Once in the terminal of choice I can run any command including programs that need the GUI. Note that if you run a prog that opens a separate window, then that new window is tied to the terminal session, if you close the terminal the other window will be killed too, and the terminal window will be stuck while the other program is running, you will get your prompt back when you close the program.

sirius56 01-02-2007 04:49 PM

When I run the following in Startup,

xterm -e cal

what happens at boot is that a Terminal window opens only for a fraction of a second (can't tell if I can see cal), and then the Gnome GUI Desktop appears.

The xterm Terminal does not persist on the Desktop.

If I run xterm alone, a terminal appears on the Gnome desktop and stays there.

anupamsr 01-02-2007 05:51 PM

Try this:

xterm -e "cal && bash"

The basic idea is that xterm runs a program and when program ends, it also ends. cal is not an interactive program so it ends just after calendar is displayed, so you need another program to tell xterm that there is still something to do.

You could write a sript running infinite loop, so you won't have to run bash, for example. Or you could right a very small application which will ask for input, almost emulating system idle process.

Here is the code:
Code:

#include <stdio.h>

int main() {
        int i;
        scanf("%d", &i);
        return 0;
}

and then just do:

xterm -e "cal && ./a.out"

sirius56 01-02-2007 06:40 PM

anupamsr, It worked! But I think it is the quote marks (" ") that made it work. Why do you think the quote marks are necessary?

Instead of cal, I tried top because top is slightly more interactive.

xterm -e "top" << added to Gnome Startup

Of course, when you Q top, the Terminal closes.

I could keep the terminal open after quitting top if I do this:

xterm -e "top && bash"

Thanks to all of you for your help.

Case closed.


BTW, In what file are all of the Startup commands, such as the ones I am entering, stored?

jonnycando 01-02-2007 06:58 PM

Quote:

Originally Posted by sirius56
anupamsr, It worked! But I think it is the quote marks (" ") that made it work. Why do you think the quote marks are necessary?

Instead of cal, I tried top because top is slightly more interactive.

xterm -e "top" << added to Gnome Startup

Of course, when you Q top, the Terminal closes.

I could keep the terminal open after quitting top if I do this:

xterm -e "top && bash"

Thanks to all of you for your help.

Case closed.


BTW, In what file are all of the Startup commands, such as the ones I am entering, stored?

I see what you were after now! Doh!

anupamsr 01-02-2007 07:03 PM

Quote:

Why do you think the quote marks are necessary?
Eh, xterm -e top && bash means
Code:

xterm -e
    top
&&
bash


xterm -e "top && bash" means
well,
Code:

xterm -e
    top
    &&
    bash

I hope it helps. Cheers and Happy new year!

sirius56 01-02-2007 07:39 PM

Case closed again. Thank you.

BTW, In what file are the Startup commands I am entering actually stored?


All times are GMT -5. The time now is 07:15 AM.