Ignore:
Timestamp:
03/30/15 14:17:55 (9 years ago)
Author:
sdipsl
Message:

house keeping in libIGCM_sys (first pass). Will ease #248

File:
1 edited

Legend:

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

    r1163 r1178  
    213213function IGCM_sys_RshMaster { 
    214214  IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ 
    215   /bin/ksh  <<-EOF 
     215  /bin/ksh <<-EOF 
    216216    export libIGCM=${libIGCM} 
    217217    export DEBUG_debug=${DEBUG_debug} 
     
    246246 
    247247#D-#================================================== 
     248#D-function IGCM_sys_RshArchive_NoError 
     249#D-* Purpose: Archive rsh command, without error 
     250#D-*          used only in monitoring.job 
     251#D-* Examples: 
     252#D- 
     253function IGCM_sys_RshArchive_NoError { 
     254  IGCM_debug_PushStack "IGCM_sys_RshArchive_NoError" $@ 
     255  /bin/ksh <<-EOF 
     256    ${@} 2> \dev\null 
     257EOF 
     258  IGCM_debug_PopStack "IGCM_sys_RshArchive_NoError" 
     259} 
     260 
     261#D-#================================================== 
    248262#D-function IGCM_sys_RshPost 
    249263#D-* Purpose: Post-process rsh command 
     
    255269    echo "IGCM_sys_RshPost :" $@ 
    256270  fi 
    257  
    258271  # keep standard input (stdin) for the loop onto temporary file 
    259   cat >tmp_IGCM_sys_RshPost_$$ 
    260  
    261 # ============ FRONTEND START ============ # 
    262  
    263   /bin/ksh <tmp_IGCM_sys_RshPost_$$ 
     272  cat >/tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 
     273 
     274  /bin/ksh </tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 
    264275  if [ $? -gt 0 ] ; then 
    265276    echo "IGCM_sys_RshPost : erreur." 
     
    267278  fi 
    268279  # delete temporary file 
    269   \rm tmp_IGCM_sys_RshPost_$$ 
     280  \rm /tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 
    270281  IGCM_debug_PopStack "IGCM_sys_RshPost" 
    271282} 
     
    299310 
    300311  if [ ! -z ${config_UserChoices_MailName} ] ; then 
    301     mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < mail.txt 
     312    mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} <  mail.txt 
    302313  elif [ -f ~/.forward ] ; then 
    303314    mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < mail.txt 
     
    347358  #- creation de repertoire sur le serveur fichier 
    348359  if [ ! -d ${1} ]; then 
    349     mkdir -p $1 
     360    \mkdir -p $1 
    350361    status=$? 
    351362 
     
    930941  fi 
    931942  if [ $DRYRUN = 0 ]; then 
    932     if [ ! -d ${1} ] ; then 
    933       echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." 
    934       IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
    935       return 
    936     fi 
    937  
    938943    typeset status 
    939944 
     
    10261031    typeset status 
    10271032    # 
    1028     if [ X${JobType} = XRUN ] ; then 
    1029       IGCM_sys_Chmod 444 ${1} 
    1030     fi 
    1031     # 
    1032     # Only if we use rsync 
    1033     #IGCM_sys_MkdirArchive $( dirname $2 ) 
    1034     # 
    1035     #USUAL WAY 
    1036     \cp $1 $2 > /tmp/out_command_${LOGIN}.$$ 2>&1 
     1033    # USUAL WAY 
     1034    \cp $1 $2 > /tmp/out_command.$$ 2>&1 
    10371035    status=$? 
    10381036 
     
    10531051    if [ ${status} -gt 0 ] ; then 
    10541052      echo "IGCM_sys_Put_Rest : cp failed error code ${status}" 
    1055       cat /tmp/out_command_${LOGIN}.$$ 
     1053      [ -f ${1} ] && ls -l ${1} 
     1054      [ -f ${2} ] && ls -l ${2} 
     1055      [ -f ${2}/${1} ] && ls -l ${2}/${1} 
     1056      cat /tmp/out_command.$$ 
    10561057      IGCM_debug_Exit "IGCM_sys_Put_Rest" 
    10571058    else 
    1058       \rm /tmp/out_command_${LOGIN}.$$ 
     1059 
     1060      if [ X${JobType} = XRUN ] ; then 
     1061        [ -f ${2} ] && IGCM_sys_Chmod 444 ${2} 
     1062        [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1} 
     1063      fi 
     1064 
     1065      \rm /tmp/out_command.$$ 
    10591066    fi 
    10601067  fi 
     
    10801087 
    10811088    typeset status 
    1082     # 
    1083     if [ X${JobType} = XRUN ] ; then 
    1084       IGCM_sys_Chmod 444 ${1} 
    1085     fi 
    1086  
    10871089    # 
    10881090    # USUAL WAY 
     
    10971099      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
    10981100    else 
    1099       \rm /tmp/out_command_${LOGIN}.$$ 
     1101 
     1102      if [ X${JobType} = XRUN ] ; then 
     1103        [ -f ${2} ] && IGCM_sys_Chmod 444 ${2} 
     1104        [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1} 
     1105      fi 
     1106 
     1107      \rm /tmp/out_command.$$ 
    11001108    fi 
    11011109  fi 
     
    12131221      i=0 
    12141222      while [ $i -lt $NB_ESSAI ] ; do 
    1215         # USUAL WAY 
    1216         \cp $1 $2 > /tmp/out_command_${LOGIN}.$$ 2>&1 
    1217         status=$? 
     1223        if [ $( stat -c %d $1 ) -ne $( stat -c %d $( dirname $2 ) ) ] ; then 
     1224          # USUAL WAY 
     1225          \cp $1 $2 > /tmp/out_command.$$ 2>&1 
     1226          status=$? 
     1227        else 
     1228          # NOT SO USUAL WAY 
     1229          \mv $1 $2 > /tmp/out_command.$$ 2>&1 
     1230          status=$? 
     1231        fi 
    12181232        if [ ${status} -gt 0 ]; then 
    12191233          IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed error code ${status} ${i}/${NB_ESSAI}" 
     
    12331247      [ -f ${2} ] && ls -l ${2} 
    12341248      [ -f ${2}/${1} ] && ls -l ${2}/${1} 
    1235       cat /tmp/out_command_${LOGIN}.$$ 
     1249      cat /tmp/out_command.$$ 
    12361250      IGCM_debug_Exit "IGCM_sys_PutBuffer_Out" 
    12371251    else 
     
    13871401    echo "IGCM_sys_GetDate_FichWork :" $@ 
    13881402  fi 
     1403 
     1404  if [ $# -ge 3 ] ; then 
     1405    mode=$3 
     1406    TimeStyle=$4 
     1407  else 
     1408    mode="default" 
     1409    TimeStyle="%Y%m%d%H%M%S" 
     1410  fi 
     1411 
    13891412  typeset dateF 
    1390   set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) 
    1391   eval ${2}=${dateF[5]} 
     1413  set +A dateF -- $( ls -l --full-time --time-style=+"${TimeStyle}" ${1} ) 
     1414 
     1415  case $mode in 
     1416    "default") 
     1417      eval ${2}=${dateF[5]} 
     1418      ;; 
     1419    "SplitFields") 
     1420      eval ${2}="${dateF[5]}\ ${dateF[6]}" 
     1421      ;; 
     1422  esac 
     1423 
    13921424 
    13931425  # donne la date filesys d'un fichier sur la machine work 
     
    15771609  #  0  118 110.0000000000000   87.46478873239437 
    15781610  #  1  40  4.999999999999995   51.97183098591550 
     1611 
    15791612#  typeset iStation iProc list_opt file_in file_out prefix_invert 
    15801613#  typeset -Z4 j4 
Note: See TracChangeset for help on using the changeset viewer.