LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 10-13-2010, 07:41 PM   #1
disc0stu
LQ Newbie
 
Registered: Jul 2003
Posts: 7

Rep: Reputation: 0
Question 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.
 
Old 10-13-2010, 09:32 PM   #2
rikijpn
Member
 
Registered: Jun 2007
Location: Japan
Distribution: Debian lenny, DSL, Solaris 10
Posts: 157

Rep: Reputation: 33
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).
 
Old 10-13-2010, 09:46 PM   #3
disc0stu
LQ Newbie
 
Registered: Jul 2003
Posts: 7

Original Poster
Rep: Reputation: 0
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.
 
Old 10-14-2010, 10:59 PM   #4
rikijpn
Member
 
Registered: Jun 2007
Location: Japan
Distribution: Debian lenny, DSL, Solaris 10
Posts: 157

Rep: Reputation: 33
Quote:
Originally Posted by disc0stu View Post
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.
 
  


Reply

Tags
gnome, terminal


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
run command in new gnome-terminal checkchan Linux - General 10 08-29-2012 04:55 AM
How do I resize the terminal window from the command line in the gnome terminal QuIcKSpArK Linux - Newbie 5 04-21-2012 03:04 PM
Is command line invocation of gnome-terminal to run more than one command possible? narnie Programming 4 02-17-2010 11:39 PM
Problem in launching a terminal command with a Qt Button hdinn Programming 6 02-10-2010 09:50 AM
How to close terminal window when launching app from command line Casket Linux - Newbie 8 11-02-2007 07:05 AM


All times are GMT -5. The time now is 10:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration