My favorites | Sign in
Project Logo
                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/sh

JOBS=${JOBS:-10}

screenlist() {
screen -ls | awk '/^[\t ]/ {print $1}'
}

capture_all() {
screenlist \
| egrep -v SCREENTMP \
| xargs -n1 -P${JOBS} sh -c 'screen-session-hardcopy.sh $1 2> /dev/null' -
}

OUTDIR=${OUTDIR:-$(mktemp -d)}
if [ -z "$OUTDIR" -o ! -d "$OUTDIR" ] ; then
echo "mktemp -d failed or \$OUTDIR is not a directory."
fi

export OUTDIR

capture_all

FILES="$(find $OUTDIR -type f)"

set -- `getopt twl "$@"`
while [ $# -gt 0 ]; do
case $1 in
-t)
FILES="$(ls $OUTDIR/*:p)"
;;
-w)
FILES="$(ls $OUTDIR/* | grep -v ':p$')"
;;
-l)
LOCATIONONLY=1
FILES="$(ls $OUTDIR/*:p)"
;;
--)
break
;;
esac
shift;
done

MATCHES="$(grep -l "$@" $FILES)"

# Filter out our current screen session if we're running this from
# within a screen already.
if [ ! -z "$STY" ] ; then
MATCHES="$(echo "$MATCHES" | grep -Fv "$STY")"
fi

for M in $MATCHES ; do
fsty=$(echo $(basename $M) | awk -F: '{print $1}')
fwin=$(echo $(basename $M) | awk -F: '{print $2}')
if [ "$fwin" = "p" ] ; then
if [ "$LOCATIONONLY" -eq 1 ] ; then
linecmp=$(awk 'NF > 1 {print $(NF - 1)}' $M \
| egrep -n "$@" \
| awk -F: '{printf("NR == %d ||", $1)}' \
| sed -e 's/ ||$//')
fwin="$(awk "$linecmp {print \$1}" $M)"
else
fwin="$(egrep "$@" $M | awk '{ print $1 }')"
fi
fi

echo "sty $fsty window $fwin"
done

rm -rf "$OUTDIR"
rm -f /tmp/log.*
Show details Hide details

Change log

r1953 by jordansissel on Jul 07, 2008   Diff
- Fix bug when all content is scanned (use
find instead of ls)
- Change output to be more script and
human friendly.
Go to: 
Project members, sign in to write a code review

Older revisions

r1951 by jordansissel on Jul 07, 2008   Diff
- Make debug logging optional
r1950 by jordansissel on Jul 07, 2008   Diff
- Make a SLEEP variable so I can tweak
the sleep delays globally.
- Call egrep when necessary
- Added proper option parsing
- New search abilities:
...
r1949 by jordansissel on Jul 07, 2008   Diff
- Add screen session multiwindow
screen scraping.
  Both of these scripts must be in
your $PATH

...
All revisions of this file

File info

Size: 1497 bytes, 73 lines

File properties

svn:executable
*
Hosted by Google Code