-   Linux - Software (
-   -   Is there anyway to execute bash as interactive and run a command? (

nfirvine 06-20-2009 10:37 PM

Is there anyway to execute bash as interactive and run a command?
I'm trying to start bash with a command and have it interactive like this:

bash -i -c "echo Welcome!"

As in, execute the command and allow me to use it as an interactive shell afterwards. (I'm doing something more complicated than echoing, but this doesn't work.)

I've tried this from a running gnome-terminal, from one gnome-terminal to a new one with


and from the Alt+F2 program launcher (with "Run in terminal" ticked).

Any ideas?

jdkaye 06-21-2009 01:01 AM

Google is your friend.
bash startup message
result (among many others):
have fun,

nfirvine 06-22-2009 04:40 AM

Nope, that's not what I'm looking for.

Here's the situation: Whilst programming junk, I like to have a couple of terminals open, to different directories, and one running ipython in the source directory. So I'm going to need to run a couple of different commands. I don't want to have to replace my .bashrc.

chrism01 06-22-2009 07:36 PM

Maybe I don't follow you, but why not just open half a dozen gnome-terminals before you start?

nfirvine 06-23-2009 03:28 AM

Yeah, that's what I'm trying to do. Except I'd like to do it from a script (easy) and have each of them execute a separate command (e.g., change directory, start ipython, set some environment variables). I reckon I could switch out the .bashrc before each call, but that seems like the wrong way to do it.

colucix 06-23-2009 04:02 AM

So the problem is to open a new terminal from the command line executing a command and keep it open for interactive usage, right? Take a look at a solution here. You can try to write a function that do the trick or even some aliases, each of them running a specific command.

nfirvine 06-24-2009 12:19 AM

That's exactly what I wanted. The gnome-terminal -x switch is the key, and it's not in the --help. It is in the man page, however, so I suppose I should have RTFM. :P

All times are GMT -5. The time now is 08:25 AM.