Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I start my screen connection with a spawn command within an expect script: spawn screen /dev/...

But I don't know how I can kill the screen when the script is finished

share|improve this question

1 Answer 1

up vote 1 down vote accepted

When you run screen, use the -S option to give it a unique session name. Then, you can send it commands with the -X option. The quit command will kill the screen, like so:

$ screen -S myscreen -d -m
$ screen -ls
There is a screen on:
        2651.myscreen (09/06/2012 04:56:06 PM)        (Detached)
1 Socket in /var/run/screen/S-username.
$ screen -S myscreen -X quit
$ screen -ls
No Sockets found in /var/run/screen/S-username.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.