Last active
July 16, 2021 17:33
-
-
Save SippieCup/8adca7eef220c6d4659ff951e3cf3b57 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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
Usage: ./sender.sh PATH LISTENING_HOST PORT DELETE
ex. Usage: ./sender.sh /mnt/dest/00 192.168.0.5 3001 false
This does not delete the plots after transferring
or
ex. Usage: ./sender.sh /mnt/dest/00 farmer 3001 true
This does.