LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Is there anyway to execute bash as interactive and run a command? (http://www.linuxquestions.org/questions/linux-software-2/is-there-anyway-to-execute-bash-as-interactive-and-run-a-command-734482/)

nfirvine 06-20-2009 09: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

gnome-terminal

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

Any ideas?

jdkaye 06-21-2009 12:01 AM

Google is your friend.
bash startup message
result (among many others):
http://ubuntuforums.org/showthread.php?t=580470
have fun,
jdk

nfirvine 06-22-2009 03: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 06: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 02: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 03: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-23-2009 11:19 PM

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 02:31 AM.