10 # --- Call on errors -------------------------------------------------
13 echo "$@" > /dev/stderr
17 # --- Help -----------------------------------------------------------
21 Usage: $0 -p PID -f FILE [OPTIONS]
24 -p,--pid PID Process identifier
25 -f,--file FILENAME File to monitor
26 -o,--out NAME Name of stored file
27 -w,--wait SECONDDS How many seconds to wait
28 -P,--pipe Use a tee when writing to file
31 Output file is PID_NAME.log. If NAME is not specified it defaults to
32 the base name of FILENAME minus possible ending .log.
37 # --- Process command line -------------------------------------------
38 while test $# -gt 0 ; do
40 -p|--pid) pid=$2 ; shift ;;
41 -f|--file) file=$2 ; shift ;;
42 -o|--out) out=$2 ; shift ;;
43 -w|--wait) twait=$2 ; shift ;;
45 -h|--help) usage ; exit 0 ;;
46 *) error "Unknown option: $1" ;;
51 # --- Check settings -------------------------------------------------
52 if test "X$pid" = "X" ; then error "No PID specified" ; fi
53 if test "X$file" = "X" ; then error "No file specified" ; fi
54 if test "X$out" = "X" ; then
55 out=`basename $file .log`
58 # --- Make derived variables -----------------------------------------
62 # --- Check grid authenticity ----------------------------------------
63 if test ! -f /tmp/gclient_env_${UID} ; then
64 error "No AliEn environment file"
66 . /tmp/gclient_env_${UID}
67 alien-token-info | grep -q "Token is still valid"
68 if test $? -ne 0 ; then
69 echo "Token not valid, please re-new" > /dev/stderr
74 # --- Main loop (eternal) --------------------------------------------
76 if test $tee -gt 0 ; then
77 echo "=== Executing alien_spy $pid $file | tee $tmp ..."
78 alien_spy $pid $file | tee $tmp
80 echo "=== Executing alien_spy $pid $file > $tmp ..."
81 alien_spy $pid $file > $tmp
85 if test $l1 -ge $l2 ; then
88 echo "New download smaller than old - exiting"