我想做以下事情:
我写了下面的脚本来做上面的事情:
#!/bin/bash
echo "hello"
gnome-terminal -x bash -c "cd ~/automation/DVF99_Automation/Scripts;pwd;gedit sample.txt;python test.py;exec $SHELL"
echo "good bye"
上面给了我以下输出:
user4@user-pc-4:~/Desktop$ ./DAT_run.sh
hello
good bye
在打开的新 gnome 终端上,我看到以下消息:
/home/user4/Scripts
From python script
From python script
From python script
From python script
From python script
以上表示它已经执行了 python 代码,并且满足了我的要求 1,2 和 4(不是第 3 个)。在保存并关闭
gedit
窗口之前,我无法将其作为前台进程保留(以便仅在我关闭 gedit
中打开的文件后才执行下一条语句)。
这里可能出了什么问题?我是 shell 脚本的新手,觉得我很可能在这里遗漏了一些东西。我怎样才能达到以上所有要求?
顺便说一句,你需要在后台启动 gedit。
例子:
$ gedit sample.txt&;python test.py;exec $SHELL"
更好的是可变替换。
#!/she/bang
FILE=sample.txt
gedit $(FILE)&;python test.py;exec $SHELL"