#!/bin/ksh ## ## Script: set_pwd ## Where: in $FEDIR/scripts where FEDIR = /apps/nns_com/fea ## ######################################################################## ## PURPOSE: This script ## 1. Prompts/navigates for/to a directory name to be made the current ## working directory (CWD). ## 2. If the directory is not known to the user, the user can enter a * to see ## the sub-directories of the current directory (ls -ald) and ## mouse-enter a directory name at a repetion of the directory name ## prompt. ## ######################################################################## ## CALL FORMAT: . $FEDIR/scripts/set_pwd ## ######################################################################## ## WHERE USED: ## The 'set_pwd' script is used by other $FEDIR/scripts cmds ## that perform a command on all the files (or ## a 'group/mask of files') in a directory. ## ## Can find scripts where-used using the ./FIND_IN_NOT_OLD script ## in the $FEDIR/scripts directory, using 'set_dir' as the input string. ## ######################################################################## ## MAINTENANCE HISTORY: ## Written by: Blaise Montandon C61 4Jan96 ## Updated by: Blaise Montandon C61 18Sep97 chgd /proj# to /data ## Updated by: Blaise Montandon O06 5Mar99 chgd name from 'set_dir' ## to 'set_pwd'; touched up ## comments & interface ######################################################################## ######################################################################## ##### START OF dirname-prompt while loop ############################## ######################################################################## dirname1="continue" while test "${dirname1}" = "continue" do echo "${HIbold}\ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA Directory-Navigator -- to a current working directory (CWD):${HIreset} DIR-LIST: For a LIST of sub-directories of the current directory, enter * DIR: (mouse-)ENTER name of a DIRECTORY ... fully-qualified OR relative to the current directory. Directory Examples:${HIdim} /usr/people/$USER OR /data/subs/cae/$USER OR /local/scratch/$USER OR /local/scratch OR to accept the CURRENT directory, use . OR to go up ONE level , use .. OR to go up TWO levels , use ../.. OK: Enter NULL to accept current directory as the working directory. ${HIreset} CURRENT DIRECTORY: `pwd` ${HIbold}\ (mouse-)ENTER * or DIRname or NULL ==>${HIreset} \c" read dirname1 ## For testing: # set -x if test "${dirname1}" = "" then break # continue # exit fi ##################################################### ## Routine that is executed if the response is a '*'; ## i.e. show all sub-directories: ##################################################### if test "${dirname1}" = "*" then echo " ${HIbold}VVVVVVVVVVVVVVVVV SUB-DIRECTORIES VVVVVVVVVVVVVVVVVVVVVV${HIreset}" ls -al | awk '/^d/ { print $0 }' dirname1="continue" continue fi ################################################## if test -d ${dirname1} then ################################################## ## START OF routine that is executed if ## the response is a directory name: ################################################## echo " ....................................................................... Changing directory ... " set -x cd ${dirname1} set - ################################################## ## Check to see if this is the directory that the ## user wants to be the (current) working directory (CWD). ################################################## echo " Is `pwd` where you want to be? n or y Default = n ==> \c" read dir_ok if test "${dir_ok}" = "y" then break else echo " ${HIbold}TRY AGAIN.${HIreset} " dirname1="continue" fi ################################################## ## END OF routine that is executed if ## the response is a directory name: ################################################## else ################################################## ## START OF routine that is executed if ## the response is NOT a directory name: ################################################## echo "${HIbold} ${dirname1} NOT FOUND. TRY AGAIN.${HIreset} " dirname1="continue" ################################################## ## END OF routine that is executed if ## the response is NOT a directory name: ################################################## fi ## For testing: # set - done ######################################################################## ##### END OF dirname-prompt while loop ############################## ########################################################################