FSUDAQ/DAQ/elogEntry.sh

65 lines
1.7 KiB
Bash
Executable File

#!/bin/bash -l
source ~/FSUDAQ/FSUDAQ.sh
echo "======================================= making elog Entry"
echo ${DataPath}
echo ${ExpName}
echo ${ElogIP}
elogIDFile=${DataPath}"/elogID.txt"
source ${elogIDFile}
echo ${ElogID}
isStart=$1
Comment=$2
elogFileName=${DataPath}"/elogText.txt"
echo ${isStart}
echo ${Comment}
if [ ${isStart} == "1" ]; then
#make text file for elog text
echo "**************************************" > ${elogFileName}
echo "Run-${lastRunID} start at $(date)" >> ${elogFileName}
echo ${Comment} >> ${elogFileName}
#push to elog
IDStr=$(elog -h ${ElogIP} -l ${ExpName} -u GeneralFox fsuphysics888 -a Author="GeneralFox" -a Category="Run" -a RunNo=${lastRunID} -a Subject="Run Log" -n 2 -m elogText.txt)
IDStr=$(echo ${IDStr} | tail -1 | awk '{print $4}')
echo ${IDStr}
if [ ${IDStr:0:3} == "ID=" ] && [[ ${IDStr:3} =~ ${re} ]]; then
elogIDStr="Elog"${IDStr}
echo "Elog is succefully pushed at ${elogIDStr}"
echo ${elogIDStr} >> ${elogIDFile}
fi
else
elogFileName2=elogText2.txt
#download elog entry
echo "====== getting elog entry"
elog -h ${ElogIP} -l elog/${ExpName} -u GeneralFox fsuphysics888 -w ${ElogID} > ${elogFileName2}
echo "======================="
cat ${elogFileName2}
# echo "remove header"
# cutLineNum=$(grep -n "==============" ${elogFileName2} | cut -d: -f1)
# #check encoding
# encoding=$(grep "Encoding" ${elogFileName2} | awk '{print $2}')
# if [ $encoding = "plain" ]; then encodingID=1 ; fi
# if [ $encoding = "HTML" ]; then encodingID=2 ; fi
# if [ $encoding = "ELcode" ]; then encodingID=0 ; fi
# #remove all header
# sed -i "1,${cutLineNum}d" ${elogFileName2}
fi