LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   launching interactive gnome-terminal with a command (and not exiting) (http://www.linuxquestions.org/questions/programming-9/launching-interactive-gnome-terminal-with-a-command-and-not-exiting-837905/)

disc0stu 10-13-2010 06:41 PM

launching interactive gnome-terminal with a command (and not exiting)
 
I want to have a script (tcsh/bash/python) that launches a bunch of gnome-terminals (or 1 with multiple tabs). And I want it to execute a command, but keep the shell interactive. Currently, if you type gnome-terminal then it launches a new interactive shell, but if you give it the execute flag, then it executes the command and quits (or stays open, but non-interactive depending on the users gnome-terminal settings).

I have this command which I want to run automatically before I start working. What the command does is dynamic and different for each shell. It takes arguments. So it's not something I can take care of in a .cshrc type file.

rikijpn 10-13-2010 08:32 PM

what command are you using?
 
I did a test script like this:
Code:

#!/bin/bash

echo "$1"

exec bash

And executed it like this:
Code:

gnome-terminal --command="./temp.sh hey"
And it worked.

I don't know how are you executing your script (what arguments/options to what programs).
But also running "bash -i" apparently makes it interactive. "exec bash" means replace the current shell for "bash", thus running a new bash instead of the current... which may, or may not be want you want (you can use it as a shell, but if the script you ran made some variables you needed you should "export" them to be used in the new shell too).

disc0stu 10-13-2010 08:46 PM

Unfortunately, that doesn't do exactly what i want. It is just running the echo command and then starting a new shell. It's not actually echoing that command in the new shell.

Thanks for your help.

rikijpn 10-14-2010 09:59 PM

Quote:

Originally Posted by disc0stu (Post 4126608)
Unfortunately, that doesn't do exactly what i want. It is just running the echo command and then starting a new shell. It's not actually echoing that command in the new shell.

Thanks for your help.

The code I showed you is obviously just one example.
You'd have to replace the echo... part, with whatever code you actually want to put. You said the command took arguments, and echo is an obvious easy to get example.

You could always give a more detailed example, or better, the actual code of your script for a better answer.


All times are GMT -5. The time now is 05:58 PM.