How to write a shell script that runs commands in separate terminals?











up vote
1
down vote

favorite












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










share|improve this question


























    up vote
    1
    down vote

    favorite












    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










    share|improve this question
























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      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










      share|improve this question













      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







      command-line bash scripts






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Oct 13 '16 at 8:52









      Andy Bennett

      2112




      2112






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          4
          down vote













          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






          share|improve this answer






























            up vote
            0
            down vote













            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






            share|improve this answer























              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "89"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














               

              draft saved


              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f836410%2fhow-to-write-a-shell-script-that-runs-commands-in-separate-terminals%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              4
              down vote













              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






              share|improve this answer



























                up vote
                4
                down vote













                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






                share|improve this answer

























                  up vote
                  4
                  down vote










                  up vote
                  4
                  down vote









                  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






                  share|improve this answer














                  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







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Apr 13 '17 at 12:24









                  Community

                  1




                  1










                  answered Oct 13 '16 at 9:18









                  Zanna

                  48.9k13123234




                  48.9k13123234
























                      up vote
                      0
                      down vote













                      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






                      share|improve this answer



























                        up vote
                        0
                        down vote













                        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






                        share|improve this answer

























                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote









                          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






                          share|improve this answer














                          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







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Apr 13 '17 at 12:23









                          Community

                          1




                          1










                          answered Oct 13 '16 at 10:01









                          Nizar Malangadan

                          584




                          584






























                               

                              draft saved


                              draft discarded



















































                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f836410%2fhow-to-write-a-shell-script-that-runs-commands-in-separate-terminals%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Ellipse (mathématiques)

                              Quarter-circle Tiles

                              Mont Emei