#!/bin/bash # Check if argument is provided if [ $# -eq 0 ]; then echo "No arguments provided" echo "./check_writable.sh [path to directory to test]" exit 3 fi # Check if directory exists if [ ! -d "$1" ]; then echo "UNKNOWN - $1 is not a directory" exit 3 fi # Check if directory is writable if [ -w "$1" ]; then echo "OK - $1 is writable" exit 0 else echo "CRITICAL - $1 is not writable" exit 2 fi