Hi,
I'm trying to launch a new gnome terminal which will execute a bash command and when that command exits, will return to the bash interactive command line as if I had typed that command myself. I then want to be able to press the up arrow and retrieve the command executed. essentially I have been trying gnome-terminal -e 'bash command' type commands to get gnome-terminal to launch a new terminal which executes the command like I mentioned. The bash commands I've been trying are
would have been perfect, except that this launches a non-interactive terminal which exits as soon as the command finishes.
Code:
bash -s -c 'command'
or
Code:
bash -i -c 'command'
don't work either since it seems that the -c option overrides the -s and -i options.
I also tried piping the command to the command line like:
Code:
echo "command" | bash -i
But this doesn't quite work either, because bash automatically submits the command 'exit' after 'command' finishes.
Finally, I found the following stack overflow entries which look promising.
http://stackoverflow.com/questions/7...mmand-executes
http://stackoverflow.com/questions/8...n-this-session
These suggestions actually work if you execute the bash command in the same terminal and aren't launching a new terminal with gnome-terminal! This behaviour is what I want, except somehow the string is getting mangled when I pass the command to gnome-terminal for execution.
For instance executing
Code:
bash --rcfile <(echo ". ~/.bashrc && command")
in a terminal gives the expected behaviour.
However
Code:
gnome-terminal -e 'bash --rcfile <(echo ". ~/.bashrc && command")'
fails because it's actually looking for a file instead of using the output of the echo command. I assume this is because of some bash string mangling which I can't figure out how to undo. Literally every combination of quotes and escapes of suspect characters I've tried seems to end in failure. For example:
Code:
gnome-terminal -e 'bash --rcfile <(echo ". ~/.bashrc && ls")'
gives:
Code:
bash: . ~/.bashrc && ls): No such file or directory
Can somebody explain how I can unmangle the string I'm passing to gnome-terminal, or tell me a better way I can do this? Thanks a lot for any help!
Bookmarks