Progress on the screen shutdown script

A few months ago I mentioned a script intended to gracefully shut down all the programs I normally run in screen, and bring the entire session to a halt. As things are now I have to step through each program and issue the native “quit” command(s), which isn’t terrible, but with only minor variations, should be easily handled through a script.

The problem of course, is that some of those programs, like mc or hnb just as examples, need control characters to quit cleanly, and through screen’s stuff command, things get a little hairy.

Boldewyn‘s post from a few days ago gets me a little closer to where I want to be. With the keypress sequences mentioned there, my script now looks like this.

#!/bin/bash
screen -p alpine -X stuff qy
screen -p centerim -X stuff ^[^[qq
screen -p elinks -X stuff Q
screen -p hnb -X stuff ^Qy
screen -p htop -X stuff q
screen -p mc -X stuff "exit ^M"
screen -p vim -X stuff :wq!
screen -p wyrd -X stuff Q

The CTRL+V keypress to “translate” the control characters to text was a big step forward. The long, backslash-preceded codes that I was using before were being sent through as straight keypresses, but this sends through a command character, which works well for things like mc or hnb.

Usually. It’s odd, but it seems like sometimes, the script works but sometimes things still get huddled up on mc’s prompt line, or hung at hnb’s save-before-closing prompt. Sometimes it seems like the script will work if it’s executed from within screen, but not if it’s cued from another tty or if screen is detached. This is definitely better and sometimes seems to get the job done, but it’s just not “there” yet — to borrow a phrase from Linux detractors. :twisted:

In any case, I will continue to pursue this, and see if I can pin down the when and the where of the why it doesn’t quite do the trick. :)

About these ads

3 Responses to “Progress on the screen shutdown script”


  1. 1 Dieter_be 2010/07/08 at 5:27 AM

    hmm. what are you smoking?
    Don’t these programs respond to sigterm? If not, patch them to do so. It would be much cleaner then this ;-)

  2. 2 Gullars 2010/07/08 at 3:47 PM

    If you had taken the time to read the comments on the original post you would be wiser, I’ll suggest you do that before trying to be a smart ass…

  3. 3 Dieter_be 2010/07/09 at 2:01 AM

    I was not trying to be a smart ass, only a funny pants.
    and actually i did see those comments.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




Welcome!



Visit the Wiki!

Some recent desktops


May 6, 2011
Musca 0.9.24 on Crux Linux
150Mhz Pentium 96Mb 8Gb CF
 


May 14, 2011
IceWM 1.2.37 and Arch Linux
L2300 core duo 3Gb 320Gb

Some recent games


Apr. 21, 2011
Oolite on Xubuntu 11.04
L2300 core duo 3Gb 320Gb

Enter your email address to subscribe to this blog and receive notifications of new posts.

Join 405 other followers

License

This work is licensed under the GNU Free Documentation License. Please see the About page for details.

Blog Stats

  • 3,960,744 hits

Archives


Follow

Get every new post delivered to your Inbox.

Join 405 other followers

%d bloggers like this: