# [SOLVED] Scripting - running command in new terminal



## HCMustard (Jul 13, 2009)

Trying to write a script that will run multiple commands, and will run some of those commands within a new terminal window.

Each of my commands work on their own.

I have found how to do it with

gnome-terminal -x sh -c <command>

However a few of the commands I want to run start with
python /path/program.py
And it will open in a new terminal, but at the python prompt instead of running the full command.

On its own it will run the full command.

I've tried with the command in brackets to no avail.

I'm completely new to this and was able to Google myself this far, but now I am stuck 

Thanks


----------



## hal8000 (Dec 23, 2006)

*Re: Scripting - running command in new terminal*



HCMustard said:


> Trying to write a script that will run multiple commands, and will run some of those commands within a new terminal window.
> 
> Each of my commands work on their own.
> 
> ...


That's not a bash script but a Python program you are trying to run.
To call a python program from bash try:

#!/bin/sh
python /pathtoprogram/prog.py

Save the script and make it executable e.g. chmod 755


----------



## HCMustard (Jul 13, 2009)

*Re: Scripting - running command in new terminal*

Thanks.
How would I put that all together then?

gnome-terminal -x sh c #!/bin/sh python/path/program.py

?

----

Here is essential what I am trying to do.

#start
clear
mount -t cifs path1 /mnt/path1
mount -t cifs path2 /mnt/path2

python/path/program1.py
python/path/program2.py
/path/program3
#end

They all work on their own. But the programs continue to run in terminal, so they need to be in their own windows.

So that is why I started playing around with
gnome-terminal -x sh -c


----------



## hal8000 (Dec 23, 2006)

*Re: Scripting - running command in new terminal*

Try starting tasks in background:


#!/bin/sh
clear
mount -t cifs path1 /mnt/path1
mount -t cifs path2 /mnt/path2
python/path/program1.py &
python/path/program2.py &
/path/program3 &
#end

save file as test.sh in your home directory and then do
chmod 755 test.sh

To run it use

./test.sh


----------



## HCMustard (Jul 13, 2009)

*Re: Scripting - running command in new terminal*

The running in background part is what I needed, and that seems to have done the trick.

Thank you muchly!


----------



## hal8000 (Dec 23, 2006)

*Re: Scripting - running command in new terminal*



HCMustard said:


> The running in background part is what I needed, and that seems to have done the trick.
> 
> Thank you muchly!


Ok, you're welcome, just edit your first post and append [solved] to title please.


----------

