PDA

View Full Version : [ubuntu] Keeping the gnome-terminal session active



shemhamforash
July 18th, 2009, 10:41 AM
Heya all,

I've added a new item to the main gnome menu. I choose for the type "Application in Terminal", and as command let's say running the command "nmap".

What I want to achieve is that when i click on the link, a new instance of gnome-terminal opens, and "nmap" is executed. Just with no arguments yet, so that I get to see all the available options. I have ~100 programs that I want to add to this menu, all just running with the "--help" parameter or the like, and opening the gnome-terminal in the right working directory. Just like in backtrack for example.

The problem:

The new instance of gnome-terminal does open successfully, but closes immediately. I can set the option in gnome-terminal to keep the terminal open after a program exits, but then I'm stuck with a inactive terminal (program exited, and the prompt doesn't return). Is there an option to keep the gnome-terminal session active?

I looked for answers for a long time, and posting here is the last thing there's left for me..

wojox
July 18th, 2009, 10:50 AM
In the terminal create a new profile and in the Title and Command Tab Under command click Run a custom command and enter nmap.

shemhamforash
July 18th, 2009, 10:54 AM
This means that I have to make a new profile in gnome-terminal for each of the ~100 programs I want to add to my menu?

wojox
July 18th, 2009, 10:57 AM
Yes, that is why I couldn't understand why you just wouldn't open a terminal and type you're app in to start it.

shemhamforash
July 18th, 2009, 11:02 AM
Because I have a lot of perl/python/ruby scripts residing in a specific directories.. Have you ever worked with backtrack? It has the same functionality.

shemhamforash
July 25th, 2009, 01:45 PM
So there's really no alternative for this? That's kinda disappointing..

DaithiF
July 27th, 2009, 02:23 PM
This is linux, theres always a way! :)

slightly convoluted but:
1. add this to the bottom of your .bashrc file:
if [[ -f ~/.bash-oneoff ]]; then
source ~/.bash-oneoff
fi

2. create a script called wrapper.sh:
echo "$*" > ~/.bash-oneoff
gnome-terminal
sleep 2
rm ~/.bash-oneoff

3. When creating your menu items, your command would be:
/path/to/wrapper.sh nmap --help

Note: the sleep command in 2 is to make sure that gnome-terminal has had enough time to start, launch bash, and for bash to do its initialisation stuff before we delete the .bash-oneoff file.

hope this helps