Ignore:
Timestamp:
02/13/15 15:39:23 (9 years ago)
Author:
sdipsl
Message:
  • Bugfix and simplify calls to test file existence
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libIGCM/libIGCM_sys/libIGCM_sys_ada.ksh

    r1163 r1171  
    8282typeset -r RSYNC_opt="-va" 
    8383# ie storage filesystem 
    84 ###typeset -r STOREHOST=gaya 
    8584typeset -r STOREHOST=ergon 
    8685typeset -r REMOTE_RSYNC=/u/rech/ces/rces452/RSYNC/bin/rsync 
     
    247246function IGCM_sys_RshArchive { 
    248247  IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ 
    249   typeset ergonCount gayaCount 
    250248  DEBUG_sys=false IGCM_sys_IsFileArchived "$@" 
    251   if [ $? = 0 ] ; then 
    252     status=0 
    253     #special case for the find command. Only used together with RshArchive to find tared restart 
    254     if [ "X$( echo $@ | grep ^find | grep RESTART )" != "X" ] ; then 
    255       # Ergon first 
    256       rsh ${STOREHOST} exec /bin/ksh <<-EOF > ergonList.txt 
    257     ${@} 
    258 EOF 
    259       (( status=status + $? )) 
    260       # Gaya turn 
    261       rsh gaya exec /bin/ksh <<-EOF > gayaList.txt 
    262     ${@} 
    263 EOF 
    264       (( status=status + $? )) 
    265  
    266       # the more the better 
    267       ergonCount=$( cat ergonList.txt | wc -l ) 
    268       gayaCount=$(  cat gayaList.txt  | wc -l ) 
    269  
    270       [ ${ergonCount} -ge ${gayaCount} ] && cat ergonList.txt || cat gayaList.txt 
    271       rm -f ergonList.txt gayaList.txt 
    272     else 
     249  if [ $? = 0 ] ; then     
    273250    rsh ${STOREHOST} exec /bin/ksh <<-EOF 
    274251    ${@} 
    275252EOF 
    276253    status=$? 
    277     fi 
    278254  else 
    279255    /bin/ksh <<-EOF 
     
    552528  fi 
    553529  typeset IsArchivedFlag 
    554   IsArchivedFlag=$( ( [ "X$( echo $@ | grep \/u\/ )" != "X" ] || [ "X$( echo $@ | grep \/\arch\/home )" != "X" ] ) && echo 0 || echo 1 ) 
     530  IsArchivedFlag=$( [ "X$( echo $@ | grep \/arch\/home )" != "X" ] && echo 0 || echo 1 ) 
    555531  IGCM_debug_PopStack "IGCM_sys_IsFileArchived" 
    556532 
     
    565541function IGCM_sys_TestFileArchive { 
    566542  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ 
    567   typeset ExistFlag TempCommandFile 
    568   TempCommandFile="[ -f $1 ] && echo 0 || echo 1" 
    569   #Command depends on targeted file system 
    570   #We want it quiet 
    571   DEBUG_sys=false IGCM_sys_IsFileArchived $1 
    572   if [ $? = 0 ] ; then 
    573     ExistFlag=$( IGCM_sys_RshArchive ${TempCommandFile} ) 
    574   else 
    575     ExistFlag=$( ${TempCommandFile} ) 
    576   fi 
     543  typeset ExistFlag   
     544  ExistFlag=$( IGCM_sys_RshArchive "[ -f $1 ] && echo 0 || echo 1" ) 
    577545  IGCM_debug_PopStack "IGCM_sys_TestFileArchive" 
    578546 
    579547  return ${ExistFlag} 
    580548} 
    581  
    582 #D-#================================================== 
    583 #D-function IGCM_sys_TestFileArchive 
    584 #D-* Purpose: Test file that must NOT EXISTS on Archive 
    585 #D-* Examples: 
    586 #D- 
    587 #function IGCM_sys_TestFileArchive { 
    588 #  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ 
    589 #  typeset ExistFlag finalPosition 
    590 # 
    591 #  DEBUG_sys=false IGCM_sys_IsFileArchived $1 
    592 #  if [ $? = 0 ] ; then 
    593 #    finalPosition=$( mfls $1 2>/dev/null | wc -l ) 
    594 #    [ ${finalPosition} -eq 4 ] && ExistFlag=1 || ExistFlag=0 
    595 #  else 
    596 #    ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
    597 #  fi 
    598 # 
    599 #  IGCM_debug_PopStack "IGCM_sys_TestFileArchive" 
    600 # 
    601 #  return ${ExistFlag} 
    602 #} 
    603549 
    604550#D-#================================================== 
     
    637583  IGCM_debug_PopStack "IGCM_sys_CountFileArchive" 
    638584} 
    639  
    640 #D-#================================================== 
    641 #D-function IGCM_sys_CountFileArchive 
    642 #D-* Purpose: Count files on Archive filesystem 
    643 #D-* Examples: 
    644 #D- 
    645 #function IGCM_sys_CountFileArchive { 
    646 #  IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ 
    647 #  typeset status gayaPosition ergonPosition finalPosition gayaCount ergonCount 
    648 #  #Command depends on targeted file system 
    649 #  DEBUG_sys=false IGCM_sys_IsFileArchived $1 
    650 #  if [ $? = 0 ] ; then 
    651 #    status=0 
    652 #    gayaPosition=$(  mfls ${@} 2>/dev/null | grep -n "++ Gaya"  | awk -F\: {'print $1'} ) 
    653 #    (( status=status + $? )) 
    654 #    ergonPosition=$( mfls ${@} 2>/dev/null | grep -n "++ Ergon" | awk -F\: {'print $1'} ) 
    655 #    (( status=status + $? )) 
    656 #    finalPosition=$( mfls ${@} 2>/dev/null | wc -l ) 
    657 #    (( status=status + $? )) 
    658  
    659 #    (( gayaCount  = ergonPosition - gayaPosition - 2 )) 
    660 #    (( ergonCount = finalPosition - ergonPosition )) 
    661  
    662 #    # return number of files found. greater the better 
    663 #    [ ${ergonCount} -ge ${gayaCount} ] && echo ${ergonCount} || echo ${gayaCount} 
    664  
    665 #    # "Ergon only" case 
    666 #    #IGCM_sys_RshArchive "ls ${@} 2>/dev/null | wc -l" 
    667 #    #status=$? 
    668 #  else 
    669 #    ls ${@} 2>/dev/null | wc -l 
    670 #    status=$? 
    671 #  fi 
    672 #  if [ ${status} -gt 0 ] ; then 
    673 #    echo "IGCM_sys_CountFileArchive : erreur." 
    674 #  fi 
    675 #  IGCM_debug_PopStack "IGCM_sys_CountFileArchive" 
    676 #} 
    677585 
    678586#D-#================================================== 
Note: See TracChangeset for help on using the changeset viewer.