On Aug 13, 2011, at 4:46 AM, Artur Skonecki wrote: > #!/bin/sh > # screen_hardcopy.sh > # print window scrollbacks from all GNU Screen sessions > # it breaks when session names contain spaces *sigh* > > SCREENDIR=/tmp/screens/S-$USER > HARDCOPYDIR=/tmp/screen-hardcopy-$USER > > mkdir -p $HARDCOPYDIR > > for session in $SCREENDIR/* > do > session=$(basename "$session") > mkdir -p "$HARDCOPYDIR/$session" > screen -S "$session" -X eval "hardcopydir '$HARDCOPYDIR/$session'" "at > '\#' hardcopy -h" > done > > for session in $SCREENDIR/* > do > session="$(basename "$session")" > for hardcopy in $HARDCOPYDIR/$session/* > do > winnum=$(echo "$(basename $hardcopy)" | cut -d '.' -f 2) > sed "s/.*/$session : $winnum &/" "$hardcopy" > rm "$hardcopy" > done > rmdir "$HARDCOPYDIR/$session" > done > > rmdir "$HARDCOPYDIR"
nice first cut, but doesn't work on the stock copy of screen apple ships with snow leopard macs (Screen version 4.00.03 (FAU) 23-Oct-06) first problem is session files go in some pseudo-secure /var space with a randomized name; i hacked up this to find them: case $(uname) in Darwin) SCREENDIR=$(for w in $(screen -ls|tr -d \\r|cat -v|grep .|tail -1); do echo $w; done|tail -1|sed 's/.$//');; *) /tmp/screens/S-$USER;; esac (why on earth are there CRs in the output of "screen -ls"?!?) second is that this screen wants "at" to take an argument of "#", not "\#" third is that this screen interprets "hardcopy -h" as "write a hardcopy of the current screen (without scrollback) to a file named "-h" (relative to screen's pwd). i'm not entirely sure how to fix that one, as i'm not sure how to get the number of windows in a screen back out to the script. (otherwise the brute-force way would be to iterate over them, generating the name variations myself.) (i was originally going to try to fix the spaces issue, but got stuck on getting it to work at all....) -- Aaron Davies aaron.dav...@gmail.com _______________________________________________ screen-users mailing list screen-users@gnu.org https://lists.gnu.org/mailman/listinfo/screen-users