techsas_linkscript 1.79 KB
Newer Older
Yvonne Firing's avatar
Yvonne Firing committed
1 2 3 4 5 6 7 8 9
#!/bin/csh -f
#
# script by bak 3 dec 2014 for cook to allow for techsas files to be sorted into a directory
#
# modded by bak at nocs on eriu for dy031 15 may 2015, modded to run as a crontab task
#* * * * 1,2,3,4,5,6,7 /local/users/pstar/cruise/data/exec/techsas_linkscript >> & /dev/null


cd /local/users/pstar #~/h # cludge on eriu when pstar home directory is wrong
10
cd cruise/data/techsas
Yvonne Firing's avatar
Yvonne Firing committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
cd netcdf_files_links

set now = `date +%Y%m%d%H%M%S`
set link_log = /local/users/pstar/cruise/data/techsas/techsas_link_logs/techsas_link_log_${now}
echo " " >>! $link_log
echo `date` >>! $link_log

foreach techfile (`/bin/ls ../netcdf_files_rawdir/*/*`)
  set i1 = `echo $techfile | awk '{print index($1,"/")}'`
  set i2 = `echo $techfile  $i1| awk '{print substr($1,$2+1)}'`
  set i3 = `echo $i2 | awk '{print index($1,"/")}'`
  set i4 = `echo $i2  $i3| awk '{print substr($1,$2+1)}'`
  set i5 = `echo $i4 | awk '{print index($1,"/")}'`
  set linkfile = `echo $i4  $i5| awk '{print substr($1,$2+1)}'`
  if (! -e $linkfile) then
    if ( -s $techfile) then
      set sss = ` /bin/ls -l $techfile`
      set ss2 = `echo $sss | awk '{print $5}'`
      if ($ss2 > 10000) then
        echo "  making link $linkfile for raw file $techfile " >>! $link_log
31
        echo "  making link $linkfile for raw file $techfile " 
Yvonne Firing's avatar
Yvonne Firing committed
32 33 34
        ln -s $techfile $linkfile
      else
        echo "  ignoring $linkfile length $ss2 is less than 10k bytes " >>! $link_log
35 36 37
        echo "  ignoring $linkfile length $ss2 is less than 10k bytes " 
        echo "  link command would have been ln -s $techfile $linkfile " >>! $link_log
        echo "  link command would have been ln -s $techfile $linkfile " 
Yvonne Firing's avatar
Yvonne Firing committed
38 39 40
      endif
    else
      echo "  ignoring $linkfile has zero length " >>! $link_log
41
      echo "  ignoring $linkfile has zero length " 
Yvonne Firing's avatar
Yvonne Firing committed
42 43 44 45
    endif
  endif
end