Skip to content

Instantly share code, notes, and snippets.

🦅
Ready

Pritish Sehzpaul PritishSehzpaul

🦅
Ready
Block or report user

Report or block PritishSehzpaul

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@PritishSehzpaul
PritishSehzpaul / monitor_directory.sh
Created Jun 14, 2019
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.
View monitor_directory.sh
#!/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\
You can’t perform that action at this time.