Opening new terminal in shell script - linux

I am writing a shell script in Linux. I want to run some sh files in terminal and they all needs terminal themselves.
How can I open a new terminal to run another scrips?

xterm -e script arguments... &

Related

Run SH script in a new terminal window

I am currently using crontab to run a SH script at boot which navigates to the path of my python script, switches to a different python environment and runs my python script, although it works perfectly fine it runs hidden without a terminal for me to monitor whatever the python interpreter prints like errors, how could I make it so the python interpreter points at a newly opened terminal window?
Here is my SH script (runs with the bash interpreter, not sh):
#!/bin/sh
cd /
cd /home/pi/Desktop/Juvia-py
source defenv/bin/activate
python3 juvia.py &
and my crontab entry:
#reboot bash /home/pi/launcher.sh
Thank you
If you just want to record errors, you could pipe STDOUT and STDERR to files, something like
python3 juvia.py >stdout.log 2>stderr.log &
But if you wanted to open it in a separate window so you could interact you would need to manage STDIN more creatively.

Execute Command with xterm and close

Im trying to execute a program with xterm and then close xterm with program running but it seems this doesn't work like I would expect it.
In bash there is the option bash -c [command] is there something in xterm too?
Currently im using xterm -e [command] but this keeps the xterm window open till' my program has finished. But I want to open it, run the program, close it and keep the program running.
Is there a way to do it?
I do it (from a bash file) like:
my#self:~$ cat /usr/bin/rdesk.sh
#!/bin/bash
xterm -e 'perl /home/my/script.pl'
when i run the rdesk.sh file it starts xterm with a perl script, giving me some options. after choosing one, I can close the window, running the chosen program.
So you might just have to put your xterm -e ... command into a bash script.

linux bashrc alias to open terminals and run individual scripts

I am trying to make a shortcut alias that does the following for me:
opens a new terminal and inside that new terminal it cd's to a directory and runs a script.
At the same time, opens another new terminal and inside that new terminal it cd's to a directory and runs a script.
I have tried the following:
alias launchmystuff='cd /path/to/directory1/ && gnome-terminal && ./myscript1.sh; cd /path/to/directory2/ && gnome-terminal && ./myscript2.sh'
There are two problems with this:
It opens 1 terminal and is waiting for myscript1.sh to finish BEFORE launching the second terminal.
The terminal that opens and runs the script does not have "possession" of the script that is running. The original terminal that the alias is typed into has "possession" of the scripts that are running. So if I close any of the newly created terminals, the script will not die.
Ideally I would like two terminals to open at once, each running their unique scripts, and for each of them to kill the script when I close their respective terminals.
Does anyone know how to accomplish this?
Thank you
You need to pass the script as an argument to gnome-terminal, rather than running it in the current shell after starting gnome-terminal. As usual, you should use a shell function instead of an alias here.
launchmystuff () {
cd /path/to/directory1/ && gnome-terminal -e ./myscript1.sh
cd /path/to/directory2/ && gnome-terminal -e ./myscript2.sh
}

Run a shell script in a new cygwin window

How can I run a shell script in a new cygwin window? The following just opens up the windows type of cmd window which is difficult to resize.
cygstart /cygdrive/c/cygwin/bin/bash ~/runmyapp.sh
Well, if you want to keep the window open after the script exits, you have to do something to make the shell that is executing the script not exit.
Here's an example that should work.
mintty bash -c "~/runfxtransact.sh; read -p \"Press enter to close this window.\"" &

excel shell command launching a bash script fails

I have a simple shell script that returns a file.
Shell ("c:\cygwin64\bin\bash --login '/cygdrive/c/cygwin64/home/me/bin/sp2 '" & Parm1)
This fails as a shell command but works when sent via command line
Is there anyway I can keep the cmd window open when running via the Excel shell command, to see what errors are being encountered.
Thanks

Resources