开发者

Opening a new terminal window & executing a command

I've been trying to open a new terminal window from my application and execute a command开发者_JAVA百科 on this second window as specified by the user. I've built some debugging software and I would like to execute the user's program on a separate window so my debugging output doesn't get intermixed with the programs output.

I am using fork() and exec(). The command I am executing is gnome-terminal -e 'the program to be executed'.

I have 2 questions:

  1. Calling gnome-terminal means the user has to be running a gnome graphical environment. Is there a more cross-platform command to use (I am only interested in Linux machines though)?

  2. After the command finishes executing the second terminal also finishes executing and closes. Is there any way to pause it, or just let it continue normal operation by waiting for input?


You probably want something like xterm -hold.


1) gnome-terminal should work reasonably also without the whole gnome environonment, anyway the old plain "xterm" is enough.

2) you can execute a short bash script that launch your program and at the end reads a line:

bash -c 'my program ... ; read a'

(or also 'xterm -e ...')

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜