bash - Shell script opening multiple terminals and executing distinct commands [closed]

可紊 提交于 2019-12-22 10:36:36

问题


I've tried to write my own shell script. So far I've managed to open 4 xterminals that can only execute ONE command because of the 'hold' option.

If i don't use this option, the terminals just disappear.

Here is my code :

#!/bin/sh
xterm -title "App 1" -hold -e mycommand | mysecondcommand  &
xterm -title "App 2" -hold -e mycommand | mysecondcommand  &
xterm -title "App 3" -hold -e mycommand | mysecondcommand  &
xterm -title "App 4" -hold -e mycommand | mysecondcommand

Not so sure if I'm supposed to execute the second command in the same terminal that way.

Any ideas ?

Thank you


回答1:


Without -hold, the xterm will close as soon as the command is completed. You can execute multiple commands by using double quotes and command separators (eg ;, &):

xterm -title "App 1" -e "mycommand; mysecondcommand" 


来源:https://stackoverflow.com/questions/22656359/bash-shell-script-opening-multiple-terminals-and-executing-distinct-commands

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!