LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   I don't want the terminal to exit! (https://www.linuxquestions.org/questions/linux-software-2/i-dont-want-the-terminal-to-exit-347108/)

dbcoder 07-26-2005 07:54 PM

I don't want the terminal to exit!
 
Well, I have a small problem that hopefully one of you can help me with.


I'm making my fluxbox menu right now, and I have one command like [exec] (fortune) {gnome-terminal -e fortune}

The problem is that it when fortune ends, the terminal ends. All I want to know is if there is a way to keep that terminal open.

Thanks in advance.

rose_bud4201 07-26-2005 08:27 PM

If you just want fortune to run when you open a terminal, I'd suggest putting the call to fortune in your .bashrc, rather than in your menu. Every time you open a terminal, your .bashrc is run anew for that particular instance of the terminal.
That way your fluxbox menu entry is just [exec] (terminal) {gnome-terminal}, and fortune will run itself each time you open it.

Code:

[me@localhost ~]$ cat .bashrc
export PATH=$PATH:/usr/sbin/:/home/laura/OpenOffice.org1.1.0/program:/usr/gnat/bin:/usr/java/jdk1.3.1_07/bin/
export PYTHONPATH=/usr/local/lib/python2.2/site-packages/gtk-2.0/:/usr/local/lib/python2.2/site-packages/

#aliases
alias ls="ls --color"
alias ll="ls -l"
alias umount="sudo umount"
alias mount="sudo mount"
alias shutdown="sudo /sbin/shutdown"

#Customize bash prompt to look human...
PS1="[\u@\h \w]\\$ "

#The last thing in the file
echo "What is your command, my mistress?"
                                                                <--- put 'fortune' in here somewhere

(The other option, if you're intent on doing it the way you've got set up, is *maybe* to add a '&': {gnome-terminal -e fortune &} ...but I'm not sure that'll work. It may not even bring up the window that way)

dbcoder 07-26-2005 08:32 PM

Quote:

Originally posted by rose_bud4201
If you just want fortune to run when you open a terminal, I'd suggest putting the call to fortune in your .bashrc, rather than in your menu. Every time you open a terminal, your .bashrc is run anew for that particular instance of the terminal.
That way your fluxbox menu entry is just [exec] (terminal) {gnome-terminal}, and fortune will run itself each time you open it.

(The other option, if you're intent on doing it the way you've got set up, is *maybe* to add a '&': {gnome-terminal -e fortune &} ...but I'm not sure that'll work. It may not even bring up the window that way)


Thanks for your help, but I'd want a way to keep the console up after a command is completed. I have several other programs that will exit after they are finished and would like to find a way to keep it up.


The & didn't work :-(.

dbcoder 07-27-2005 10:50 PM

I don't know if bumping is rude, but this is on the third page and I would really like some help.

dbcoder 07-28-2005 10:00 AM

I hope I'm not being annoying, but bump?! I would really like some help.

rose_bud4201 07-28-2005 10:31 AM

From all I've seen on Google and trying this myself, you can't do what you want...rxvt just ain't gonna make it happen. If you want a terminal to stay up after you run a program, open rxvt through your menu, and then run whatever program it is you want to run.

trickykid 07-28-2005 10:50 AM

Quote:

Originally posted by rose_bud4201
From all I've seen on Google and trying this myself, you can't do what you want...rxvt just ain't gonna make it happen. If you want a terminal to stay up after you run a program, open rxvt through your menu, and then run whatever program it is you want to run.
Fortune is a simple program designed to display text in your terminal or console, when it displays the random text, it's done. By running in a terminal, it's going to close which is not either the terminal's issue or fortune, it's just how it works. Fortune was not intended to run by a X menu or icon but rather for messages when you login, etc.

My suggestion would be if you really want to be able to click on 'fortune' and read it by the terminal window staying open long enough, write a simple script that calls fortune and then perhaps sleeps for however long you want it to stay open for, which will cause the terminal to stay open for however many seconds you set it to...

I did a test and it worked.. the script would be as followed for you:

Code:

#!/bin/bash
# Script to make the terminal stay open long enough to read the fortune

gnome-terminal -e fortune

# Sleep for 2 minutes so I can read the fortune
sleep 120

Then just name this script whatever you want and place in /usr/bin or whereever and edit your menu to point to this script instead of the gnome-terminal -e fortune portion... so it would look like this:

[exec] (fortune) {/path/to/new/script}

And come to think of it, you could probably just add the sleep portion at the end of your existing fortune link in the menu like this:

[exec] (fortune) {gnome-terminal -e fortune && sleep 120}

ahh 07-28-2005 11:01 AM

You could use an xterm instead.
Code:

xterm -hold -e fortune

trickykid 07-28-2005 11:03 AM

Quote:

Originally posted by ahh
You could use an xterm instead.
Code:

xterm -hold -e fortune

That's true too.. xterm is better than all other terminals anyways.. ;)

dbcoder 07-28-2005 03:41 PM

Quote:

Originally posted by ahh
You could use an xterm instead.
Code:

xterm -hold -e fortune


So close to what I would like. Thanks for your help.

But if it's possible, is there a way that you could return to the prompt to enter commands afterwards?

dbcoder 07-28-2005 08:56 PM

I tried gnome-terminal && fortune, but that didn't do a thing. I wonder if there is a way to run a command pointed to a specific terminal open. Hrrrm.

ahh 07-29-2005 01:18 AM

Quote:

Originally posted by dbcoder
So close to what I would like. Thanks for your help.

But if it's possible, is there a way that you could return to the prompt to enter commands afterwards?

I don't think it is, but the man page for xterm has a *lot* of options. There may be something there...

dbcoder 07-29-2005 10:19 AM

I've looked and there isn't anything that would help/

Man, I really hope this is possible.

rose_bud4201 07-29-2005 10:28 AM

Why can't you just have a menu option that opens a terminal, and then just run the command that you want to run? Since you want the terminal to remain active anyway, it can't be that you don't like using the commandline....? The menu won't save you that much time in the long run, really it won't.

If they're complicated program names, or have long options and so on, you could always just set up an alias for them.

in .bashrc:
alias short_cut="long_winded_program_name -with -lots -of -options"

dbcoder 07-29-2005 07:00 PM

Because it's kinda the whole scheme of my fluxbox configuration. It's just not for fortune, that's just an example.


All times are GMT -5. The time now is 03:41 PM.