#!/bin/sh -u # $0 pathname # Find non-executable files and present a menu of choices. # -IAN! idallen@ncf.ca export PATH=/bin:/usr/bin umask 022 # First check the input argument for validity. # if [ $# -ne 1 ] ; then echo 1>&2 "$0: Expecting one argument, found $# ($*)" exit 1 fi if [ ! -f "$1" ] ; then echo 1>&2 "$0: '$1' is not an existing file" exit 1 fi # If the argument is executable, do nothing. # (This is not an error.) # if [ -x "$1" ] ; then echo "'$1' is executable" exit 0 fi # This menu contains the prompt; put the whole menu on stderr # cat <&2 === Your Menu === 1. Display the first 7 lines of the file 2. Delete the file 3. Add execute permission to the file 4. Move the file to the /tmp directory q. Quit Enter a selection: EOF read sel case "$sel" in 1) head -7 "$1" || exit $? ;; 2) rm "$1" || exit $? ;; 3) chmod +x "$1" || exit $? ;; 4) mv "$1" /tmp || exit $? ;; q) exit 0 ;; *) echo 1>&2 "$0: '$sel' is not recognized menu selection [1234q]" exit 1 ;; esac exit 0