Skip to content

Instantly share code, notes, and snippets.

View PritishSehzpaul's full-sized avatar
🦅
Ready

Pritish Sehzpaul PritishSehzpaul

🦅
Ready
View GitHub Profile
@PritishSehzpaul
PritishSehzpaul / monitor_directory.sh
Created June 14, 2019 08:45
A shell script that monitors a directory for new or moved(/renamed) images and executes a program(C program, in my case) that takes the file's location and uploads it to the server. After executing the process keeps on running in the background and watches every new file that comes.
#!/bin/bash
# NOTE: To avoid any word splitting or globbing issues you should always try to use double quotes around the variable name
# Specify any new extensons or filenames over here that you want monitored for changes
FILES_MONITORED=( .+\.jpe?g .+\.png .+\.bmp .+\.JPE?G .+\.PNG .+\.BMP )
# TODO: Update the description
if [[ "$#" -eq 0 ]] || [[ "$#" -eq 1 ]]; then
printf "Upload program's location must be specified. Directory to be monitored must be specified. \n\
[USAGE]: ./monitor_directory.sh \"directory\" \"path-to-upload-file\"\n\n\