[SOLVED] How do I run a command on a separate terminal in a bash script?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
The script gets created as '~/Something.sh' but executed as './Something.sh', which would only be correct if the current working directory is '~/' I see no syntax error, however the script is so short that it closes the window almost immediately. If you do something more like
That was not what I wanted to do, I want my script to open a whole new shell console and start running my second script on that console. Like the main script is a root which triggers several sub-scripts to start running, each on a new shell console, Separately, and my main all my main terminal does would be creating the sub-scripts not running them.
That was not what I wanted to do, I want my script to open a whole new shell console and start running my second script on that console. Like the main script is a root which triggers several sub-scripts to start running, each on a new shell console, Separately, and my main all my main terminal does would be creating the sub-scripts not running them.
Did you read theNbomr's post?
You're creating ~/Second.sh but executing ./Second.sh. What if the working directory is not $HOME?
What exactly do you mean by 'a whole new shell console'? When you make the changes I previously suggested, what does it do or not do that you see as incorrect?
just confirming what others said before: above code works and opens an xterm nicely; If you want to run more xterms concurrently from the same script, you should run them in the background of course. (&)
Since your script is writing a script, you also need to write the shebang to the script:
No.
xterm is told what to interpret it with in the -e option. If you don't specify it, it assumes the shell.
EDIT: looking at the xterm man page, I found a problem! it says:
Quote:
-e program [ arguments ... ]
This option specifies the program (and its command line arguments) to be run in
the xterm window. It also sets the window title and icon name to be the base‐
name of the program being executed if neither -T nor -n are given on the command
line. This must be the last option on the command line.
It is the last argument. Everything following the '-e' is considered part of that argument (at least in the examples here). Although there are elements within it that look like option arguments, they are for the command which will be launched by xterm, and are considered to be lumped together as part of the '-e' argument to xterm. I usually enclose the whole thing in quotes to enforce this, although evidently, this is not required.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.