#!/bin/sh -u # Perform several tests on the first argument to this script. # If no arguments, do the tests on /etc/passwd instead. # -IAN! idallen@idallen.ca # First, find out which pathname we are going to be testing. # if [ $# -ge 1 ] ; then # use first argument as pathname (BAD: ignores other arguments) path="$1" echo "Using first argument: $1" else # use a default because first argument is missing path="/etc/passwd" echo "Script has no arguments; using default path: $path" fi echo "You are using pathname '$path'." if [ -e "$path" ] ; then echo "The path '$path' exists" else echo "The path '$path' does not exist" \ "(or is missing or inaccessible)" fi if [ -d "$path" ] ; then echo "The path '$path' is a directory" else echo "The path '$path' is not a directory" \ "(or is missing or inaccessible)" fi if [ -f "$path" ] ; then echo "The path '$path' is a plain file" else echo "The path '$path' is not a plain file" \ "(or is missing or inaccessible)" fi if [ -r "$path" ] ; then echo "The path '$path' is readable" else echo "The path '$path' is not readable" \ "(or is missing or inaccessible)" fi if [ ! -w "$path" ] ; then echo "The path '$path' is not writable" \ "(or is missing or inaccessible)" else echo "The path '$path' is writable" fi if [ ! -x "$path" ] ; then echo "The path '$path' is not executable" \ "(or is missing or inaccessible)" else echo "The path '$path' is executable" fi