views:

99

answers:

1

Hi,

Can we open a new terminal tab or window from the existing terminal using a makefile or some c file.

If yes how? Thanks in advance for replying.

P.S. I want to do this because first in the terminal I want to run the server file then I want to open the new terminal and there run the file for the client.

From the second terminal I want to continue running the script.

+1  A: 

You could try running xterm (the most available terminal window program) with the program to run as the shell argument.

xterm ./my_client &

For this to work the DISPLAY environmental variable would have to be set to something usable (which it probably will be if you are running X windows locally -- if you are connecting remotely then it's more complicated).

If you want to get fancy you can try to determine what other terminal window programs are available and what the user would want to use, but I know some of them have a different way of specifying which "shell" to run.

nategoose
This gives me an error ---->>>>> xterm Xt error: Can't open display: xterm: DISPLAY is not set
abhishekgupta92
I said DISPLAY had to be set. If you aren't using X windows you should use the screen method mention by someone else, but since you said open another window I assumed that you were using one of the many terminal emulator programs (xterm, gnome-terminal, konsole, ...) and launching another X program from within one of them usually works as DISPLAY is usually (correctly) set.
nategoose
Actually, This worked on my computer. But we are supposed to get this running in our Labs computers where we cannot install anything at our will. The piece of code is giving error there.
abhishekgupta92
nategoose