LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 01-02-2007, 03:29 PM   #1
sirius56
Member
 
Registered: Nov 2006
Location: Illinois
Distribution: Ubuntu 10.4
Posts: 35

Rep: Reputation: 15
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.
 
Old 01-02-2007, 03:56 PM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,093

Rep: Reputation: 300Reputation: 300Reputation: 300Reputation: 300
Check out the -e argument to xterm, i.e. do "xterm -e myprogram". You can find more details in "man xterm".
 
Old 01-02-2007, 04:36 PM   #3
jonnycando
Member
 
Registered: Nov 2006
Location: Virginia
Distribution: OpenSuSE 10.2
Posts: 121

Rep: Reputation: 15
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.

Last edited by jonnycando; 01-02-2007 at 04:39 PM. Reason: add more thoughts
 
Old 01-02-2007, 04:49 PM   #4
sirius56
Member
 
Registered: Nov 2006
Location: Illinois
Distribution: Ubuntu 10.4
Posts: 35

Original Poster
Rep: Reputation: 15
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.
 
Old 01-02-2007, 05:51 PM   #5
anupamsr
Member
 
Registered: Sep 2004
Location: India
Distribution: Kubuntu, Archlinux, Suse, Gentoo, Mandrake
Posts: 370

Rep: Reputation: 30
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"
 
Old 01-02-2007, 06:40 PM   #6
sirius56
Member
 
Registered: Nov 2006
Location: Illinois
Distribution: Ubuntu 10.4
Posts: 35

Original Poster
Rep: Reputation: 15
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?
 
Old 01-02-2007, 06:58 PM   #7
jonnycando
Member
 
Registered: Nov 2006
Location: Virginia
Distribution: OpenSuSE 10.2
Posts: 121

Rep: Reputation: 15
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!
 
Old 01-02-2007, 07:03 PM   #8
anupamsr
Member
 
Registered: Sep 2004
Location: India
Distribution: Kubuntu, Archlinux, Suse, Gentoo, Mandrake
Posts: 370

Rep: Reputation: 30
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!

Last edited by anupamsr; 01-02-2007 at 07:05 PM.
 
Old 01-02-2007, 07:39 PM   #9
sirius56
Member
 
Registered: Nov 2006
Location: Illinois
Distribution: Ubuntu 10.4
Posts: 35

Original Poster
Rep: Reputation: 15
Case closed again. Thank you.

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
can i run a php program to connect to mysql db 4.0 in terminal supritipanda Programming 4 08-11-2006 11:11 AM
how do you run a program from terminal? fatbeaver Linux - Newbie 1 04-26-2006 12:41 PM
any way to continue using the terminal while any program is being run? g_srinivas Linux - Newbie 6 07-20-2005 08:30 AM
How to run a program on another terminal SharpyWarpy Linux - General 2 02-10-2005 02:09 PM
how do i run GNOME from the terminal? help! kissmeimgerman Linux - Software 1 04-03-2004 01:35 AM


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

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration