GNU 屏幕:从 bash 脚本启动时 -S 选项不起作用
拥有如此简单的 bash 脚本:
/bin/bash
screen -dm -S "backup"
wget -O backup-$(date +%Y-%m-%d).txt http://link-to-very-huge-file/
问题是:当执行 screen -dm -S "backup" 时,会出现新的 screen 会话。但它没有命名!当我(从 ssh)执行 screen -ls
时,它给了我:
(10/09/2011 04:35:05 PM)(已分离) 1969.VNC (10/09/2011 01:53:45 PM)(分离) 910.minecraft (10/09/2011 12:59:29 PM)(分离)
最后两个是我自己创建的。但是第一个是由 bash 脚本创建的,没有名称,甚至没有 id!
当我自己执行 screen -dm -S "backup" 时,它工作正常并为我提供了命名的屏幕会话:
3527.backup (10/09/2011 04:44:40 PM)(已分离)
但为什么脚本效果不好呢?怎样才能让它正常工作呢?
Having such simple bash script:
/bin/bash
screen -dm -S "backup"
wget -O backup-$(date +%Y-%m-%d).txt http://link-to-very-huge-file/
The problem is: when screen -dm -S "backup"
executes, new screen session appears. But it's not named! When I (from ssh) do screen -ls
it gives me:
(10/09/2011 04:35:05 PM) (Detached) 1969.VNC (10/09/2011 01:53:45 PM) (Detached) 910.minecraft (10/09/2011 12:59:29 PM) (Detached)
I've created the last two myself. But the first one, created by bash script, doesn't have name and even doesn't have id!
When I do screen -dm -S "backup"
myself, it works fine and gives me the named screen session:
3527.backup (10/09/2011 04:44:40 PM) (Detached)
But why script does bad? How to make it work propertly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这很奇怪;它对我有用。
您可以复制并粘贴 bash 脚本的准确内容吗?您问题中的第一行缺少
#!
,并且在screen
命令后面的一行上有wget
命令。这让我怀疑问题出在您没有向我们展示的某些代码中。这是我刚刚尝试过的。 (我添加了
-c /dev/null
以避免加载相当复杂的.screenrc
文件):我在 Ubuntu 11.04 上使用 screen 4.00.03jw4。
That's odd; it works for me.
Can you copy-and-paste the exact contents of the bash script? The one in your question is missing the
#!
on the first line, and has thewget
command on a line following thescreen
command. This makes me suspect the problem is in some code you haven't shown us.Here's what I just tried. (I added the
-c /dev/null
to avoid loading my fairly elaborate.screenrc
file):I'm using screen 4.00.03jw4 on Ubuntu 11.04.