1

I've never written a script before, and I need help with my first one.

I have 3 commands, that need to run in order, in separate windows.

How do i write a script that I can execute, that runs command one, command two, and command three, in order, in separate windows?

I have tried making sense out of other posts, but haven't had any luck

2 Answers2

4

You can do it just by calling three instances of your terminal emulator and telling them to stay open with exec bash

Example:

#!/bin/bash
mate-terminal -x bash -c 'uname -r; exec bash'
mate-terminal -x bash -c 'uname -m; exec bash'
mate-terminal -x bash -c 'uname -s; exec bash'

The first terminal pops up with 4.4.0-42-generic second one with x86_64, third one with Linux...

If you're using vanilla Ubuntu, then replace mate-terminal with gnome-terminal or whatever app you use. Replace uname -[rms] with your commands. You may find you need to use -e and not -x for gnome-terminal.

Help from this answer posted by Chaos

Zanna
  • 70,465
0

Assume that the commands are command_1, command_2 .. command_n. Then do the following

(You can also use terminal, or konsole, or gnome-terminal, instead of xterm, as mentioned here ).

 $ xterm -e command_1
 $ xterm -e command_2
 .
 .
 $ xterm -e command_n