开发者

GNU Screen: -S option doesn't work when launched from bash script

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)

B开发者_如何学运维ut why script does bad? How to make it work propertly?


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 the wget command on a line following the screen 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):

$ screen -ls
There is a screen on:
        2454.pts-1.kvetch       (09/09/2011 11:00:03 AM)        (Detached)
1 Socket in /var/run/screen/S-kst.

$ cat foo.bash
#!/bin/bash

screen -dm -S FROM_BASH -c /dev/null sleep 12345
$ ./foo.bash
$ screen -ls
There are screens on:
        10384.FROM_BASH (10/09/2011 01:22:48 PM)        (Detached)
        2454.pts-1.kvetch       (09/09/2011 11:00:03 AM)        (Detached)
2 Sockets in /var/run/screen/S-kst.

$ 

I'm using screen 4.00.03jw4 on Ubuntu 11.04.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜