#!/bin/csh -f #+ # outdir -- set/show the current output directory # # Purpose: # With no arguments, print the name of the current data # directory. With one argument, change the OUTDIR keyword to # point to the named directory (creating it if requested). If # files already exist in the output directory, the FRAMENO is # reset to be 1 higher than the highest existing image number in # order to prevent overwriting of existing images. # # Usage: # outdir [dir] # # Arguments: # dir = new directory to which to set the OUTDIR keyword # # Output: # output directory name is printed to stdout # # Restrictions: # # Exit values: # 0 = normal completion # 1 = wrong number of arguments # 2 = unable to create directory # # Example: # 1) to show the existing output directory: # outdir # 2) to set the OUTDIR to "/sdata1001/deimos1/2003jan01": # outdir /sdata1001/deimos1/2003jan01 # #- # Modification history: # 2000-Jul-04 GDW Original version # 2002-Jun-06 GDW Adapted for DEIMOS # 2010-Apr-12 GDW Modified to prevent trailing backslash #----------------------------------------------------------------------- set buf = $0 set cmd = $buf:t set usage = "Usage: $cmd [dir]" # verify args... if ( $#argv > 1 ) then printf "$usage\n" exit 1 endif if (${#argv} == 1) then set dir = $1 set exists = 0 if ( ! -e $dir ) then printf "Directory not found. Create it now? (y/n) [y]: " set ans = $< if ( "$ans" != "" && "$ans" != "y" && "$ans" != "Y" ) exit 2 mkdir $dir if ( ! -e $dir ) then printf "ERROR: could not create directory %s\n" $dir exit 2 endif else if ( -e $dir && ! -d $dir ) then printf "ERROR: $dir exists but is not a directory\n" exit 2 else set exists = 1 endif # remove trailing backslash... while ( $dir =~ /*/ ) set dir = $dir:h end # reset the outdir... modify -s deiccd outdir = $dir # if the directory already existed, then reset frameno to last_image+1 # to prevent overwriting existing images... if ( $exists ) then printf "Resetting frame number to prevent overwriting old images...\n" nextframe endif else show -s deiccd -terse outdir endif