Linux Blog

Screen Script, Part Deux

Filed under: Shell Script Sundays — TheLinuxBlog.com at 6:09 pm on Sunday, May 3, 2009

So, the last script for handling the screen didn’t quite work out as I had liked so I have stopped using it. Basically if you try to SCP something, it would flip out because there was no terminal. Also, if you were trying to do anything in X after logging in with SSH you would have to detach your screen session first, which could get annoying. I’ve came up with this snippet, its rather ugly but is intended to be run after you log in if you want to start a screen session. I’d like a solution that logs me in with this sort of dialog selection but also allows X and scp transfers to work if a selection is not made. Perhaps it could be done on a timer. Anyhow, here is the script:

screen -r $(dialog --stdout --menu Test 20 50 10 `echo $(screen -ls | grep \( | sed -e 's/\t/,/g' | cut -d , -f 2- | awk -F ',' '{print $1,$2}' | awk -F '.' '{print $1,$3}' | cut -d-f 1,3)`)

It errors if no selection was made but that can be changed pretty easily by adding some if logic. Perhaps I’ll tweak it and repost, or perhaps I’ll find a better solution. Who knows.

Man Pages for commands in this post »

screen
sed
awk
dialog
echo
cut

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>