你如何使用命令启动的Unix命令屏幕? [英] How do you start Unix screen command with a command?
问题描述
按照文档为Unix的筛选命令,可以配置它.screenrc开始与一帮默认屏幕,每个运行您指定的命令。
According to the docs for the Unix "screen" command, you can configure it in .screenrc to start with a bunch of default screens, each running a command that you specify.
下面是我的cofig:
Here's my cofig:
# Default screens
screen -t "shell_0" 1
screen -t "autotest" 2 cd ~/project/contactdb ; autotest
这将不会运行自动测试命令。在那里我试图运行自动测试这个窗口
只是关闭瞬间,当我开始屏幕
。
It will not run the autotest command. That window where I'm trying to run autotest
just closes instantly when I start screen
.
我也刚刚试了一下...
I also tried it with just...
screen -t "autotest" 2 cd ~/project/contactdb
同样的结果。
我也试过...
screen -t "autotest" 2 ls
同样的结果也有。
Same result there too.
有什么秘诀让它在给定的屏幕在启动时运行命令?
What's the secret to getting it to run a command in a given screen on startup?
推荐答案
您的程序正在运行(当然,除了CD),它只是它没有父shell正在运行,所以一旦它完成,它退出就大功告成了。
Your program is being run (well, except the cd), it's just that it's being run without a parent shell, so as soon as it completes, it exits and you're done.
您可以这样做:
screen -t "autotest" 2 bash -c 'cd ~/project/contactdb ; autotest'
产卵两枚炮弹,但生活很可能会继续下去。
Spawns two shells, but life will probably go on.
这篇关于你如何使用命令启动的Unix命令屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!