0

As Stated in the title, I want to start a new terminal from (say) Terminal-1. The new Terminal will execute a command (Say, start JBoss). And after starting JBoss, there will be JBoss log in Terminal-2, so i dont want to stay there as I have some other tasks to do. I want the control back to Terminal-1, so I can execute other commands. I am running script.

Example scenario: Running a script where i need to: (1) Install JBoss (2) Start JBoss (3) Deploy a code in jboss as.

NOTE: Creating a new Terminal is not a problem. I can follow this. The problem is to come back to the primary terminal for executing further command.

user1951
  • 103

2 Answers2

0

You can simply do :

gnome-terminal -e jboss_command; exit;

That should close the new terminal as soon as the jboss_command finishes.

However, you almost certainly don't want that. There is no reason to open a new terminal. Just run your command in the background:

jboss_command &

If that creates output, run it like this:

jboss_command &>/dev/null &

The & at the end makes a command run in the background, allowing you to keep using the terminal. &>/dev/null redirects standard error and standard output to /dev/null, it basically discards any messages printed by the command. So, running your jboss command like this will enable you to keep working on the same terminal while the command is running.

terdon
  • 100,812
0

I like using 'screen' for this sort of work. You can install it with sudo apt-get install screen and use it like this:

  • Open new screen (terminal) with screen
  • Execute your command(s) in it
  • Detach it (temporarily exit) with 'ctrl+a' release keys and then press only 'd'
  • Optionally open another one and do some stuff there too, detach that one also
  • When you want to come back type screen -ls
  • And then reattach one you want with screen -r screen_name

man screen for more!

mbiber
  • 840
  • 5
  • 12
  • any alternatives to 'ctrl+a' ? I am thinking to run a script where i dont know how to use 'ctrl+a' unfortunately. – user1951 Apr 26 '14 at 11:59