# grabbing the upper window.
if [ $# -ne 1 ]; then
- echo "usage: monfold <unfold_dir>"
- exit 1
+ echo "usage: monfold <unfold_dir>"
+ exit 1
fi
DATADIR="$1"
LASTFILE=""
# Multiple close events for the same file as data is written in blocks
while read LINE; do
- DIR=`echo "$LINE" | awk '{print $1}'` # has trailing slash
- EVENT=`echo "$LINE" | awk '{print $2}'`
- FILE=`echo "$LINE" | awk '{print $3}'`
- if [ "$EVENT" != "CLOSE_WRITE,CLOSE" ]; then
- echo "Error (unexpected event '$EVENT'):"
- echo "$LINE"
- exit 1
- fi
- if [ "$FILE" != "$LASTFILE" ] && [ "$LASTFILE" != "" ]; then
- # We must have finished writing to $LASTFILE...
- echo "process $DIR$LASTFILE -> $OUTFILE"
- ln -s "$DIR$LASTFILE" "$DATALINK"
- gnuplot "$GPFILE"
- rm "$DATALINK"
- echo $ACTION
- $ACTION
- fi
- LASTFILE="$FILE"
+ DIR=`echo "$LINE" | awk '{print $1}'` # has trailing slash
+ EVENT=`echo "$LINE" | awk '{print $2}'`
+ FILE=`echo "$LINE" | awk '{print $3}'`
+ if [ "$EVENT" != "CLOSE_WRITE,CLOSE" ]; then
+ echo "Error (unexpected event '$EVENT'):"
+ echo "$LINE"
+ exit 1
+ fi
+ if [ "$FILE" != "$LASTFILE" ] && [ "$LASTFILE" != "" ]; then
+ # We must have finished writing to $LASTFILE...
+ echo "process $DIR$LASTFILE -> $OUTFILE"
+ ln -s "$DIR$LASTFILE" "$DATALINK"
+ gnuplot "$GPFILE"
+ rm "$DATALINK"
+ echo $ACTION
+ $ACTION
+ fi
+ LASTFILE="$FILE"
done < <(inotifywait -q -m -e CLOSE_WRITE --exclude '.*unfold_.*' "$DATADIR")
rm "$GPFILE"