dtst() # test the survey from the latest dem directory { # takes at most 2 arguments project="$1" # project number should be first argument if [[ $# == 0 ]]; then # check the number of command line arguments echo "ERROR: Please supply project number" echo "Required usage: dtst 0536" echo "Optional usage: dtst 0536 2005 (project number and year)" echo "Optional usage: dtst 0536 4 (project number and demo dir)" echo "Optional usage: dtst 0536 2005 3 (project number, year and demo dir in that order)" return 1 elif [[ $# == 1 ]]; then # if only 1 argument exists proj_year=$(date +%Y) # set the project year to the current year gose ${project} demo_numb=$(ls -d demo*/ | wc -w) # store the number of demo directories elif [[ $# == 2 ]]; then # if 2 arguments exist if [[ ${#2} == 4 ]]; then proj_year="$2" # set the project year to the 2nd argument cd /kdata/${proj_year}/${project}/setup/ demo_numb=$(ls -d demo*/ | wc -w) # store the number of demo directories else proj_year=$(date +%Y) cd /kdata/${proj_year}/${project}/setup/ demo_numb="$2" fi else # if 3 arguments exist proj_year="$2" # set the project year to the 2nd argument cd /kdata/${proj_year}/${project}/setup/ demo_numb="$3" # set the desired demo directory to the 3rd argument fi if [[ ! -d ./${LOGNAME} ]]; then # if the user tesing directory does not exist mkdir ${LOGNAME} # make the user testing directory fi cd ${LOGNAME} # change to the user testing directory files_numb=$(ls | wc -w) # count the number of files in the directory if [[ ${files_numb} != "0" ]]; then # if files do exist rm -f * # remove all the files fi if [[ ${demo_numb} == 1 ]]; then # if there is only one demo directory cp -f ../demo/*.qpx . # copy the qpx from there else cp -f ../demo${demo_numb}/*.qpx . # otherwise, get it from the speicified demo dir fi ment ${project} # compile the project surv ${project} # execute the survey }