如何使用命令启动Unix屏幕命令? [英] How do you start Unix screen command with a command?

查看:219
本文介绍了如何使用命令启动Unix屏幕命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 Unix屏幕命令的文档



这里是我的cofig:

$ b,你可以在.screenrc中配置它,并运行一个你指定的命令。
$ b

 #默认屏幕
屏幕-tshell_01
屏幕-tautotest2 cd〜/ project / contactdb; autotest

它不会运行autotest命令。当我开始屏幕时,我试图运行 autotest 的窗口会立即关闭。



我也试过了...

  screen -tautotest2 cd 〜/ project / contactdb 

结果相同。



我也试过...

  screen -tautotest2 ls 



同样的结果。



让它运行命令的秘诀是什么启动时给定的屏幕?

解决方案

程序正在运行(除了cd外),它只是在运行没有父shell,因此一旦完成,就会退出并完成。



您可以:

  screen -tautotest2 bash -c'cd〜/ project / contactdb; autotest'

产生两个弹壳,但生命可能会继续。


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.

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

Same result.

I also tried...

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?

解决方案

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.

You could do:

screen -t "autotest" 2 bash -c 'cd ~/project/contactdb ; autotest'

Spawns two shells, but life will probably go on.

这篇关于如何使用命令启动Unix屏幕命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆