Find the answer to your Linux question:
Results 1 to 4 of 4
Ok so I am interested in how can I open a new terminal and execute commands in that terminal with also keeping the previous one. For example lets say that ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2010
    Posts
    6

    Bash Script Help


    Ok so I am interested in how can I open a new terminal and execute commands in that terminal with also keeping the previous one. For example lets say that I have a really simple script like this one

    #!/bin/bash

    echo "TESTING"

    echo "TESTING2"



    So what I want to happen is to output the first echo in the main terminal and then after this open a new terminal and output TESTING2 into the new terminal without closing the first one.

    Also I would like to know if it is possible to somehow protect the source code of the script so that others cant still it... I mean something like compiling the script to linux executable files...

    Thanks in advance -ac1dxtrem

  2. #2
    Linux Engineer Kloschüssel's Avatar
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    773
    Hi and welcome,

    Also I would like to know if it is possible to somehow protect the source code of the script so that others cant still it... I mean something like compiling the script to linux executable files...
    Even compiled files can be reverse engineered. The best protection is a well chosen license. In case one would do fraudulent copies, you could at least claim your copyrights. If you don't want that others see your code at all, just don't publish the code.

    So what I want to happen is to output the first echo in the main terminal and then after this open a new terminal and output TESTING2 into the new terminal without closing the first one.
    It would depend on your window system how you open a new terminal. Once you know the command that opens the terminal (i.e. in gnome it is gnome-terminal), you can figure out how to pass arguments such that the opened terminal will invoke the command you want. Invoking another command is always something like:

    command (blocks at the invoker)

    or

    command & (does not block at the invoker)
    Last edited by Kloschüssel; 10-08-2010 at 09:03 AM.

  3. #3
    Just Joined!
    Join Date
    Oct 2010
    Posts
    6
    I figured the opening new shell problem but how can I execute a command in the new shell from the script that is running in the previous shell ?

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Engineer Kloschüssel's Avatar
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    773
    You'll have to pass it to the newly created shell as an argument. How exactly that would have to look like depends ont he shell. For the gnome-terminal it would be something like:

    gnome-terminal -x commandOrScript

    Please read the manual pages for more information.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •