How to use command in text file from shell script file
am 10.09.2007 11:33:22 von BeyhanHi,
I am trying to load commands from a text file to variable and use that
variable as part of command.
code file content , test.txt:
--------------------------------------
| grep -iv ",x_pt/js/ah contract,16 Sep 2007"
| grep -iv ",x_deductshift,16 Sep 2007"
sh file
---------
#!/bin/ksh
############################################################ #####
# Program Name
############################################################ #####
PROG_NM="EA Log Pre/Post file Comparison"
############################################################ #####
# Set up environment
############################################################ #####
HOME=/hz/homedev/samigdev/saff5/Saff5Mig
FB=${HOME}
SCRIPTS=${FB}/Src/Scripts
SCRIPTLOG=FilterFilesTest.log
TEMP=${HOME}/Temp
LOG_HIST=${HOME}/History/Logs
ANT=${HOME}/ant
ANT_HOME=/hz/homedev/samigdev/ant
export ANT_HOME
ORA=/appl/oracle/8.1.7
JAVA=/usr/java130:/usr/java130/jre/bin:/usr/java130/jre/bin/ classic:/
usr/lib
LINE=`tr '\n' ' ' < ${TEMP}/test.txt`
CMD="cat ${TEMP}/AccountBalanceAfter.log ${LINE}"
# Set the PATH
PATH=${PATH}:$ANT_HOME/bin:${ORA}:${JAVA}:${HOME}/lib/xerces 123.jar:$
{HOME}/lib/jdom.jar:${HOME}/lib/log4j1.1.1.jar:/appl/oracle/ 8.1.7/lib:/
usr/local/bin:/usr/bin:/etc:/usr/sbin:/usr/java130/bin:/appl /oracle/
8.1.7/bin:/appl/oracle/8.1.7/lib:/appl/oracle/8.1.7/jdbc/lib /:/usr/
ucb:a:/usr/bin/X11:/sbin:/appl/oracle/8.1.7/jdbc/lib/classes 12.zip:/
appl/oracle/8.1.7/jdbc/lib/nls_charset12.zip:/opt:/appl/orac le/8.1.7/
jdbc/lib/jndi.zip
LIBPATH=/appl/oracle/8.1.7/lib:/appl/oracle/8.1.7/jdbc/lib:/ appl/
oracle/8.1.7/precomp/lib:/usr/lib:/usr/dt/lib
export LIBPATH
LD_LIBRARY_PATH=/appl/oracle/8.1.7/lib:/appl/oracle/8.1.7/jd bc/lib:/
appl/oracle/8.1.7/precomp/lib:/usr/lib:/usr/dt/lib
export LD_LIBRARY_PATH
CLASSPATH=/appl/oracle/8.1.7/lib/libocijdbc8.so:/appl/oracle /8.1.7/
jdbc/lib/classes12.zip:/appl/oracle/8.1.7/jdbc/lib/nls_chars et12.zip:/
opt:/appl/oracle/8.1.7/jdbc/lib/jndi.zip:$feeds/oaw:$feeds/l ib/
log4j-1.2.8.jar:$feeds/lib/jdom.jar:$feeds/lib/xerces123.jar :
export CLASSPATH
# Send all output to the log
exec 1>${TEMP}/${SCRIPTLOG} 2>&1
############################################################ #####
# Run the Diff Statements
############################################################ #####
echo "1" > ${TEMP}/check.txt
echo ${LINE} >> ${TEMP}/check.txt
echo "2" >> ${TEMP}/check.txt
echo "${CMD}" >> ${TEMP}/check.txt
#cat ${TEMP}/AccountBalanceAfter.log | grep -iv ",x_pt/js/ah contract,
16 Sep 2007" | grep -iv ",x_deductshift,16 Sep 2007"
#following line does not work ...
cat ${TEMP}/AccountBalanceAfter.log ${LINE}
# Process the result
RetVal=$?
if [ $RetVal -ne 0 ]
then
# cp $(TEMP)/$(SCRIPTLOG) $(LOG_HIST)/$(SCRIPTLOG)_$(date +'%d%m%Y')
echo "${PROG_NM} Failed on $(date +'%R %d/%m/%Y') with status $
{RetVal}"
exit $RetVal
else
cp ${TEMP}/${SCRIPTLOG} ${LOG_HIST}/${SCRIPTLOG}_$(date +'%d%m%Y')
echo "${PROG_NM} Finished Successfully on $(date +'%R %d/%m/%Y')"
exit 0
fi
###-----------------------------
Thanks