Last active
November 7, 2021 15:07
-
-
Save SippieCup/493c3a6c6f343e192f0f4af5c7189821 to your computer and use it in GitHub Desktop.
Waits for plot, transfers through network.
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