Changeset 124 for trunk/IPs/systemC/processor/Morpheo/Script/execute.sh
- Timestamp:
- Jun 17, 2009, 2:11:25 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/IPs/systemC/processor/Morpheo/Script/execute.sh
r112 r124 28 28 function execute_usage () 29 29 { 30 echo "Usage : ${0} work_dir file_cmd file_cpt file_cpu";30 echo "Usage : ${0} path_work file_cmd file_cpt file_cpu id"; 31 31 echo "Arguments : "; 32 echo " * work_dir: directory to execute command";32 echo " * path_work : directory to execute command"; 33 33 echo " * file_cmd : list of command"; 34 34 echo " * file_cpt : file with the index of next command to execute"; 35 35 echo " * file_cpu : tmp file to stock the current index"; 36 echo " * id : identification"; 36 37 exit; 37 38 } … … 40 41 function execute_test_usage () 41 42 { 42 if test ${#} -ne 4; then43 if test ${#} -ne 5; then 43 44 execute_usage; 44 45 fi; … … 58 59 local -i CPT_OLD; 59 60 local -i CPT; 60 local WORK_DIR=${1};61 local PATH_WORK=${1}; 61 62 local FILE_CMD=${2}; 62 63 local FILE_CPT=${3}; 63 64 local FILE_CPU=${4}; 64 local LOCK_CPT="${WORK_DIR}/.lock-cpt"; 65 local LOCK_CPU="${WORK_DIR}/.lock-cpu"; 66 local FILE_CMD="distexe.command"; 67 local FILE_OUT="distexe.output"; 65 local ID=${5}; 66 local LOCK_CPT="${PATH_WORK}/.lock-cpt"; 67 local LOCK_CPU="${PATH_WORK}/.lock-cpu"; 68 local OUTPUT_FILE_INFO="distexe.info"; 69 local OUTPUT_FILE_CMD="distexe.command"; 70 local OUTPUT_FILE_OUT="distexe.output"; 68 71 72 # echo " * {"$(my_date)"} <${ID}> pid is $$"; 69 73 70 74 # Init CPT if this thread is the first 71 75 lock ${LOCK_CPT}; 72 76 if test ! -s ${FILE_CPT}; then 77 echo " * {"$(my_date)"} <${ID}> create counter file ${FILE_CPT}"; 73 78 echo "0" > ${FILE_CPT}; 74 79 fi; … … 83 88 done < ${FILE_CMD}; 84 89 85 echo " * <${HOSTNAME}-$$> {"$(my_date)"}is ready";90 echo " * {"$(my_date)"} <${ID}> is ready"; 86 91 87 92 # infinite loop … … 99 104 unlock ${LOCK_CPT}; 100 105 101 106 # test if this number is valid 102 107 if test ${CPT} -ge ${#COMMAND[*]}; then 103 108 CPT=${#COMMAND[*]}; … … 110 115 # while test ${CPT}_SYNC -lt ${CPT}; do 111 116 # if test -z "${COMMAND[${CPT}_SYNC]}"; then 112 # echo " * <${HOSTNAME}-$$> {"$(my_date)"}synchronisation [${CPT}_SYNC]";117 # echo " * {"$(my_date)"} <${ID}> synchronisation [${CPT}_SYNC]"; 113 118 # fi; 114 119 # CPT_SYNC=$((${CPT}_SYNC+1)); … … 122 127 # Test if command is empty ! 123 128 if test ! -z "${COMMAND[${CPT}]}"; then 124 local CURREN_DIR=${PWD};125 cd ${ WORK_DIR}&> /dev/null;129 local PATH_CURRENT=${PWD}; 130 cd ${PATH_WORK} &> /dev/null; 126 131 mkdir "Task_${CPT}" &> /dev/null; 127 132 cd "Task_${CPT}" &> /dev/null; 128 echo " * <${HOSTNAME}-$$> {"$(my_date)"} execute command [${CPT}] : ${COMMAND[${CPT}]}"; 129 echo "${COMMAND[${CPT}]}" > ${FILE_CMD}; 130 # chmod +x ${FILE_CMD}; 131 eval "${COMMAND[${CPT}]}" &> ${FILE_OUT}; 132 cd ${CURREN_DIR} &> /dev/null; 133 # echo " * {"$(my_date)"} <${ID}> execute command [${CPT}] : ${COMMAND[${CPT}]}"; 134 echo " * {"$(my_date)"} <${ID}> execute command [${CPT}]"; 135 echo "id : ${ID}" > ${OUTPUT_FILE_INFO}; 136 echo "host : ${HOSTNAME}" >> ${OUTPUT_FILE_INFO}; 137 echo "pid : $$" >> ${OUTPUT_FILE_INFO}; 138 echo "date : "$(my_date) >> ${OUTPUT_FILE_INFO}; 139 echo "#!/bin/bash" > ${OUTPUT_FILE_CMD}; 140 echo 'source ${HOME}/.bashrc;' >> ${OUTPUT_FILE_CMD}; 141 echo "${COMMAND[${CPT}]}" >> ${OUTPUT_FILE_CMD}; 142 chmod +x ${OUTPUT_FILE_CMD}; 143 ./${OUTPUT_FILE_CMD} &> ${OUTPUT_FILE_OUT}; 144 cd ${PATH_CURRENT} &> /dev/null; 133 145 fi; 134 146 done; 135 147 136 echo " * <${HOSTNAME}-$$> {"$(my_date)"}is done";148 echo " * {"$(my_date)"} <${ID}> is done"; 137 149 138 150 lock ${LOCK_CPU}; … … 143 155 144 156 if test ${CPT} -eq 0; then 145 echo " * <${HOSTNAME}-$$> {"$(my_date)"} All task is executed";157 echo " * {"$(my_date)"} <${ID}> All task is executed on this host"; 146 158 rm ${FILE_CPU}; 147 159 fi;
Note: See TracChangeset
for help on using the changeset viewer.