Skip to content

Instantly share code, notes, and snippets.

@SippieCup
Last active November 7, 2021 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SippieCup/493c3a6c6f343e192f0f4af5c7189821 to your computer and use it in GitHub Desktop.
Save SippieCup/493c3a6c6f343e192f0f4af5c7189821 to your computer and use it in GitHub Desktop.
Waits for plot, transfers through network.
#!/bin/bash
PWD=$1
echo "Monitoring $PWD"
cd $PWD
DEST=$2
PORT=$3
DELETE=$4
inotifywait -m $PWD -e create -e moved_to |
while read dir action file; do
#echo "File '$file' appeared in directory '$dir' via '$action'"
if [ "${file: -5}" == ".plot" ]; then
# do something with the file
echo "Transferring $file to $DEST:$PORT"
tar -c $file | nc $DEST $PORT
echo 'done!'
if [ "$DELETE" = "true" ]; then
echo "removing plot"
rm $file
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment