Ignore:
Timestamp:
10/12/12 15:00:41 (12 years ago)
Author:
sdipsl
Message:
  • all available machine but IDRIS (will change soon) : print error code from mv, cp, ...
File:
1 edited

Legend:

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

    r714 r717  
    6464# Host and user names 
    6565# $hostname ou hostname 
    66 # $hostname ou hostname 
    6766typeset  HOST=${HOST:=$( hostname )} 
    6867# $username ou whoami 
     
    141140 
    142141#==================================================== 
    143 #- OUT 
     142#- R_OUT 
    144143typeset -r R_OUT=${ARCHIVE}/IGCM_OUT 
    145144 
     
    268267    status=completed 
    269268  fi 
     269 
    270270  cat  << END_MAIL > job_end.mail 
    271271Dear ${LOGIN}, 
     
    308308    fi 
    309309  fi 
    310     # vérification : 
     310  # vérification : 
    311311  if [ ! -d ${1} ] ; then 
    312312    echo "IGCM_sys_Mkdir : erreur." 
     
    326326    echo "IGCM_sys_MkdirArchive :" $@ 
    327327  fi 
    328     #- creation de repertoire sur le serveur fichier 
     328  #- creation de repertoire sur le serveur fichier 
    329329  if [ ! -d ${1} ]; then 
    330330    \mkdir -p $1 
     
    347347    echo "IGCM_sys_MkdirWork :" $@ 
    348348  fi 
    349     #- creation de repertoire sur le serveur fichier 
     349  #- creation de repertoire sur le serveur fichier 
    350350  if [ ! -d ${1} ]; then 
    351351    \mkdir -p $1 
     
    537537    IGCM_debug_Exit "IGCM_sys_Tar" 
    538538  fi 
    539  
    540539  IGCM_debug_PopStack "IGCM_sys_Tar" 
    541540} 
     
    607606#D-  Error values and explanations can depend on your system version. 
    608607function IGCM_sys_Rsync_out { 
    609   RET=$1 
    610   if [ ! $RET ] ; then 
     608  status=$1 
     609  if [ ! $status ] ; then 
    611610    echo "rsync error !" 
    612611  fi 
    613612 
    614613  if [ $MYLANG = "fr" ]; then 
    615     case $RET in 
     614    case $status in 
    616615    0)  return ;; 
    617616    1)  echo "Erreur de rsync ; RERR_SYNTAX : " 
     
    661660      echo "Temps d'attente écoulé dans l'envoi/réception de données" 
    662661      return;; 
    663     *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET 
     662    *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $status 
    664663      return;; 
    665664    esac 
    666665  elif [ $MYLANG = "en" ] ; then 
    667     case $RET in 
     666    case $status in 
    668667    0)  return;; 
    669668    1)  echo "rsync error : Syntax or usage error " 
     
    702701    30) echo "rsync error : Timeout in data send/receive " 
    703702      return;; 
    704     *)  echo "rsync error : return code of rsync unknown :" $RET 
     703    *)  echo "rsync error : return code of rsync unknown :" $status 
    705704      return;; 
    706705    esac 
     
    722721  fi 
    723722 
    724   typeset RET 
    725  
    726   echo cp --preserve=timestamps $@ > out_rsync 2>&1 
    727   \cp --preserve=timestamps $@ >> out_rsync 2>&1 
    728   RET=$? 
    729  
    730   if [ ${RET} -gt 0 ] ; then 
    731     echo "IGCM_sys_Cp : error." 
     723  typeset status 
     724 
     725  echo cp $@ > out_rsync 2>&1 
     726  \cp $@ >> out_rsync 2>&1 
     727  status=$? 
     728 
     729  if [ ${status} -gt 0 ] ; then 
     730    echo "IGCM_sys_Cp : error code ${status}" 
    732731    cat out_rsync 
    733732    IGCM_debug_Exit "IGCM_sys_Cp" 
    734733  else 
    735     rm out_rsync 
     734    \rm out_rsync 
    736735  fi 
    737736  IGCM_debug_PopStack "IGCM_sys_Cp" 
     
    749748  fi 
    750749 
    751   typeset RET 
     750  typeset status 
    752751 
    753752  echo rm $@ > out_rsync 2>&1 
    754753  \rm $@ >> out_rsync 2>&1 
    755   RET=$? 
    756  
    757   if [ ${RET} -gt 0 ] ; then 
    758     echo "IGCM_sys_Rm : error." 
     754  status=$? 
     755 
     756  if [ ${status} -gt 0 ] ; then 
     757    echo "IGCM_sys_Rm : error code ${status}" 
    759758    cat out_rsync 
    760759    IGCM_debug_Exit "IGCM_sys_Rm" 
    761760  else 
    762     rm out_rsync 
     761    \rm out_rsync 
    763762  fi 
    764763  IGCM_debug_PopStack "IGCM_sys_Rm" 
     
    777776  fi 
    778777 
    779   typeset RET 
     778  typeset status 
    780779 
    781780  echo rm $@ > out_rsync 2>&1 
    782781  \rm $@ >> out_rsync 2>&1 
    783   RET=$? 
    784  
    785   if [ ${RET} -gt 0 ] ; then 
    786     echo "IGCM_sys_RmRunDir : error." 
     782  status=$? 
     783 
     784  if [ ${status} -gt 0 ] ; then 
     785    echo "IGCM_sys_RmRunDir : error code ${status}" 
    787786    cat out_rsync 
    788787    IGCM_debug_Exit "IGCM_sys_RmRunDir" 
    789   fi 
    790  
     788  else 
     789    \rm out_rsync 
     790  fi 
    791791  IGCM_debug_PopStack "IGCM_sys_RmRunDir" 
    792792} 
     
    805805  if [ $DRYRUN = 0 ]; then 
    806806 
    807     typeset RET 
     807    typeset status 
    808808 
    809809    echo mv $@ > out_rsync 2>&1 
    810810    \mv $@ >> out_rsync 2>&1 
    811     RET=$? 
    812  
    813     if [ ${RET} -gt 0 ] ; then 
    814       echo "IGCM_sys_Mv : error in mv." 
     811    status=$? 
     812 
     813    if [ ${status} -gt 0 ] ; then 
     814      echo "IGCM_sys_Mv : error code ${status}" 
    815815      cat out_rsync 
    816816      IGCM_debug_Exit "IGCM_sys_Mv" 
    817817    else 
    818       rm out_rsync 
     818      \rm out_rsync 
    819819    fi 
    820820  else 
     
    842842    fi 
    843843 
    844     typeset RET 
    845  
    846         # Only if we use rsync 
    847         #IGCM_sys_TestDirArchive $( dirname $2 ) 
    848         # 
    849         #USUAL WAY 
    850     \cp -R $1 $2 > out_rsync 2>&1 
    851     RET=$? 
    852  
    853     if [ ${RET} -gt 0 ] ; then 
    854       echo "IGCM_sys_Put_Dir : error." 
     844    typeset status 
     845 
     846    # Only if we use rsync 
     847    #IGCM_sys_TestDirArchive $( dirname $2 ) 
     848    # 
     849    #USUAL WAY 
     850    \cp -r $1 $2 > out_rsync 2>&1 
     851    status=$? 
     852 
     853    if [ ${status} -gt 0 ] ; then 
     854      echo "IGCM_sys_Put_Dir : error code ${status}" 
    855855      cat out_rsync 
    856856      IGCM_debug_Exit "IGCM_sys_Put_Dir" 
    857857    else 
    858       rm out_rsync 
     858      \rm out_rsync 
    859859    fi 
    860860  else 
     
    866866#D-#================================================== 
    867867#D-function IGCM_sys_Get_Dir 
    868 #D-* Purpose: Copy a complete directory from $(ARCHIVE) 
     868#D-* Purpose: Copy a complete directory from ${ARCHIVE} 
    869869#D-* Examples: 
    870870#D- 
     
    881881    fi 
    882882 
    883     typeset RET 
     883    typeset status 
    884884 
    885885        #USUAL WAY 
    886886    \cp -R $1 $2 > out_rsync 2>&1 
    887     RET=$? 
    888  
    889     if [ ${RET} -gt 0 ] ; then 
     887    status=$? 
     888 
     889    if [ ${status} -gt 0 ] ; then 
    890890      echo "IGCM_sys_Get_Dir : error." 
    891891      cat out_rsync 
    892892      IGCM_debug_Exit "IGCM_sys_Get_Dir" 
    893893    else 
    894       rm out_rsync 
     894      \rm out_rsync 
    895895    fi 
    896896  else 
     
    917917    fi 
    918918 
    919     typeset RET 
     919    typeset status 
    920920 
    921921        #USUAL WAY 
    922922    cp -RL $1 $2 > out_rsync 2>&1 
    923     RET=$? 
    924  
    925     if [ ${RET} -gt 0 ] ; then 
     923    status=$? 
     924 
     925    if [ ${status} -gt 0 ] ; then 
    926926      echo "IGCM_sys_Get_Master : error." 
    927927      cat out_rsync 
     
    938938#D-#================================================== 
    939939#D-function IGCM_sys_Put_Rest 
    940 #D-* Purpose: Put computied restarts on $(ARCHIVE). 
     940#D-* Purpose: Put computied restarts on ${ARCHIVE}. 
    941941#D-           File and target directory must exist. 
    942942#D-* Examples: 
     
    948948  fi 
    949949  if [ $DRYRUN = 0 ]; then 
    950  
    951     IGCM_sys_TestDirArchive $( dirname $2 ) 
    952  
    953950    if [ ! -f ${1} ] ; then 
    954951      echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." 
    955952      IGCM_debug_Exit "IGCM_sys_Put_Rest" 
    956953    fi 
     954 
     955    typeset status 
     956    # 
    957957    if [ X${JobType} = XRUN ] ; then 
    958958      IGCM_sys_Chmod 444 ${1} 
    959959    fi 
    960960 
    961     typeset RET 
    962  
    963     echo ${RSYNC} ${RSYNC_opt} $1 $2 > out_rsync 2>&1 
    964     ${RSYNC} ${RSYNC_opt} $1 $2 >> out_rsync 2>&1 
    965     RET=$? 
    966     IGCM_sys_Rsync_out $RET 
    967  
    968     ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync 
    969     (( RET=RET+$? )) 
    970  
    971     if [ ${RET} -gt 0 ] ; then 
    972       echo "IGCM_sys_Put_Rest : error." 
     961    # 
     962    # USUAL WAY 
     963    \cp $1 $2 > out_rsync 2>&1 
     964    status=$? 
     965 
     966#       #RSYNC WITH NETWORK SSH CALL 
     967#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1 
     968#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1 
     969 
     970#       #RSYNC WITH NFS USE 
     971#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1 
     972#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1 
     973 
     974#       status=$? 
     975#       IGCM_sys_Rsync_out $status 
     976 
     977#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync 
     978#       (( status=status+$? )) 
     979 
     980    if [ ${status} -gt 0 ] ; then 
     981      echo "IGCM_sys_Put_Rest : cp failed error code ${status}" 
    973982      cat out_rsync 
    974983      IGCM_debug_Exit "IGCM_sys_Put_Rest" 
    975984    else 
    976       rm out_rsync 
     985      \rm out_rsync 
    977986    fi 
    978987  else 
     
    9991008    fi 
    10001009 
    1001     typeset RET 
     1010    typeset status 
    10021011    # 
    10031012    if [ X${JobType} = XRUN ] ; then 
     
    10081017    # USUAL WAY 
    10091018    \cp $1 $2 > out_rsync 2>&1 
    1010     RET=$? 
    1011  
    1012     if [ ${RET} -gt 0 ] ; then 
    1013       echo "IGCM_sys_PutBuffer_Rest : error." 
     1019    status=$? 
     1020 
     1021    if [ ${status} -gt 0 ] ; then 
     1022      echo "IGCM_sys_PutBuffer_Rest : error code ${status}" 
    10141023      cat out_rsync 
    10151024      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
     
    10251034#D-#================================================== 
    10261035#D-function IGCM_sys_Put_Out 
    1027 #D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly 
     1036#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly 
    10281037#D-* Examples: 
    10291038#D- 
     
    10441053    fi 
    10451054 
    1046     typeset RET 
     1055    typeset status 
    10471056        # 
    10481057    if [ X${JobType} = XRUN ] ; then 
     
    10511060      fi 
    10521061    fi 
    1053         # 
     1062    # 
    10541063 
    10551064    echo ${RSYNC} ${RSYNC_opt} $1 $2 > out_rsync 2>&1 
    10561065    ${RSYNC} ${RSYNC_opt} $1 $2 >> out_rsync 2>&1 
    1057     RET=$? 
    1058     IGCM_sys_Rsync_out $RET 
     1066    status=$? 
     1067    IGCM_sys_Rsync_out $status 
    10591068 
    10601069    ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync 
    1061     (( RET=RET+$? )) 
    1062  
    1063     if [ ${RET} -gt 0 ] ; then 
     1070    (( status=status+$? )) 
     1071 
     1072    if [ ${status} -gt 0 ] ; then 
    10641073      echo "IGCM_sys_Put_Out : error." 
    10651074      cat out_rsync 
    10661075      IGCM_debug_Exit "IGCM_sys_Put_Out" 
    10671076    else 
    1068       rm out_rsync 
     1077      \rm out_rsync 
    10691078    fi 
    10701079  else 
     
    10941103    IGCM_sys_Mkdir $( dirname $2 ) 
    10951104    # 
    1096     typeset RET 
     1105    typeset status 
    10971106 
    10981107    if [ X${JobType} = XRUN ] ; then 
     
    11041113    # USUAL WAY 
    11051114    \cp $1 $2 > out_rsync 2>&1 
    1106     RET=$? 
    1107  
    1108     if [ ${RET} -gt 0 ] ; then 
     1115    status=$? 
     1116 
     1117    if [ ${status} -gt 0 ] ; then 
    11091118      echo "IGCM_sys_PutBuffer_Out : error." 
    11101119      cat out_rsync 
     
    11281137  IGCM_debug_PushStack "IGCM_sys_Get" $@ 
    11291138 
    1130   typeset DEST RET dm_liste ifile target 
     1139  typeset DEST RET status dm_liste ifile target 
    11311140 
    11321141  if ( $DEBUG_sys ) ; then 
     
    11351144  if [ $DRYRUN -le 2 ]; then 
    11361145    if [ X${1} = X'/l' ] ; then 
    1137             # test if the first file is present in the old computation : 
     1146      # test if the first file is present in the old computation : 
    11381147      eval set +A dm_liste \${${2}} 
    11391148    else 
     
    11421151    eval DEST=\${${#}} 
    11431152 
    1144         # test if the (first) file is present in the old computation : 
     1153    # test if the (first) file is present in the old computation : 
    11451154    IGCM_sys_TestFileArchive ${dm_liste[0]} 
    1146     RET=$? 
    1147     if [ ${RET} -gt 0 ] ; then 
     1155    status=$? 
     1156    if [ ${status} -gt 0 ] ; then 
    11481157      echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." 
    11491158      IGCM_debug_Exit "IGCM_sys_Get" 
     
    11591168#       echo ${RSYNC} ${RSYNC_opt} $@ > out_rsync 2>&1 
    11601169#       ${RSYNC} ${RSYNC_opt} $@ >> out_rsync 2>&1 
    1161 #       RET=$? 
    1162 #       IGCM_sys_Rsync_out $RET 
     1170#       status=$? 
     1171#       IGCM_sys_Rsync_out $status 
    11631172 
    11641173#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync 
     
    11661175 
    11671176    if [ ${RET} -gt 0 ] ; then 
    1168       echo "IGCM_sys_Get : copy error." 
     1177      echo "IGCM_sys_Get : error" 
    11691178      cat out_rsync 
     1179      \rm out_rsync 
    11701180      IGCM_debug_Exit "IGCM_sys_Get" 
    11711181    else 
    1172       rm out_rsync 
     1182      \rm out_rsync 
    11731183    fi 
    11741184  else 
     
    11861196  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@ 
    11871197 
    1188   typeset DEST RET buf_liste ifile target file_work 
     1198  typeset DEST RET status buf_liste ifile target file_work 
    11891199 
    11901200  if ( $DEBUG_sys ) ; then 
     
    12101220    else 
    12111221      \cp ${buf_liste} ${DEST} >> out_rsync 2>&1 
    1212       RET=$? 
     1222      status=$? 
    12131223    fi 
    12141224 
    12151225    if [ ${RET} -gt 0 ] ; then 
    1216       echo "IGCM_sys_GetBuffer : copy error." 
     1226      echo "IGCM_sys_GetBuffer : error" 
    12171227      cat out_rsync 
     1228      \rm out_rsync 
    12181229      IGCM_debug_Exit "IGCM_sys_GetBuffer" 
    12191230    else 
     
    12631274#D-#================================================== 
    12641275#D-function IGCM_sys_Dods_Rm 
    1265 #D-* Purpose: Suppress files in /tmp/DODS for simulation of internet protocole. 
     1276#D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole. 
    12661277#D-* Examples: 
    12671278#D- 
     
    12761287#D-#================================================== 
    12771288#D-function IGCM_sys_Dods_Cp 
    1278 #D-* Purpose: Copy from $(ARCHIVE) files to /tmp/DODS for simulation of internet protocole. 
     1289#D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole. 
    12791290#D-* Examples: 
    12801291#D- 
     
    12881299#D-#================================================== 
    12891300#D-function IGCM_sys_Put_Dods 
    1290 #D-* Purpose: Put $(ARCHIVE) files on /tmp/DODS for simulation of internet protocole. 
     1301#D-* Purpose: Put $(ARCHIVE) files on DODS internet protocole. 
    12911302#D-* Examples: 
    12921303#D- 
     
    12961307    echo "IGCM_sys_Put_Dods :" $@ 
    12971308  fi 
    1298   if [ $DRYRUN = 0 ]; then 
    1299     RET=0 
    1300  
    1301     if [ ${RET} -gt 0 ] ; then 
    1302       echo "IGCM_sys_Put_Dods : error." 
    1303       IGCM_debug_Exit "IGCM_sys_Put_Dods" 
    1304     fi 
    1305   else 
    1306     ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1307   fi 
    13081309  IGCM_debug_PopStack "IGCM_sys_Put_Dods" 
    13091310} 
     
    13171318    echo "IGCM_sys_rebuild :" $@ 
    13181319  fi 
     1320 
     1321  typeset status 
     1322 
    13191323  /home/users/igcmg/rebuild/bin/rebuild -f -o $@ 
    1320   if [ $? -gt 0 ] ; then 
    1321     echo "IGCM_sys_rebuild : erreur ${@}." 
     1324  status=$? 
     1325  if [ ${status} -gt 0 ] ; then 
     1326    IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}" 
    13221327    IGCM_debug_Exit "rebuild" 
    13231328  fi 
Note: See TracChangeset for help on using the changeset viewer.