![]() |
|
Archives of the TeradataForumMessage Posted: Fri, 06 Feb 2009 @ 08:26:00 GMT
I think you can use 'cnsrun'.
man cnsrun
cnsrun - Runs a PDE Console Subsystem application via
single command line or an input file
[Sample script]
1) showlocks.sh
------------------------------------
#!/bin/bash
#set -x
# Must be run as root
LOGFILE=/tmp/showlocks.txt
LOCK_RESULTWK=/tmp/showlock_reswk.txt
LOCK_RESULTF=/tmp/showlock_res.txt
/usr/pde/bin/cnsrun -utility showlocks -file /dev/null -debug 1 |
/usr/bin/tee ${LOGFILE}
if [ "$?" -ne "0" ]
then
echo "showlocks abnormal end" | /usr/bin/tee -a ${LOGFILE}
exit 1
else
echo "showlocks normal end" | /usr/bin/tee -a ${LOGFILE}
fi
LOCK_RESULT=`./find_lockinf.pl ${LOGFILE} | /usr/bin/tee
${LOCK_RESULTWK}`
/bin/cat ${LOCK_RESULTWK} | \
/usr/bin/grep -v "AMP Number" | \
/usr/bin/grep -v "There are currently no host utility locks in the
DBC" | \
/usr/bin/grep -v "ShowLocks Processing Complete" | \
/usr/bin/sed '/^$/d' | /usr/bin/sed '/^ $/d' | /usr/bin/tee
${LOCK_RESULTF}
GREP_RESULT=`/bin/cat ${LOCK_RESULTF} | /usr/bin/wc -l`
if [ "${GREP_RESULT}" -eq "0" ]
then
echo "Locking tbl nothing" | /usr/bin/tee -a ${LOGFILE}
else
echo "Locking tbl exists" | /usr/bin/tee -a ${LOGFILE}
/bin/cat ${LOCK_RESULTF} | /usr/bin/tee -a ${LOGFILE}
fi
exit 0
------------------------------------
2) find_lockinf.pl
------------------------------------
#!/usr/bin/perl
# run as root
while (<>) {
if ( /--AMP Number/ .. /--ShowLocks Processing Complete--/ ){
print;
}
}
------------------------------------
Since message format varies depending on Tera version, grep lines or perl script may need some slight modification. This script spends more than 10 seconds to finish in our environment, I don't know the exact reason. But anyway it can be non-interactive showlocks. Hope this helps. Masa Yumoto
| ||||||||||||||||||||||||||||||||||||||||||||||||
| | ||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||
| Copyright 2016 - All Rights Reserved | ||||||||||||||||||||||||||||||||||||||||||||||||
| Last Modified: 15 Jun 2023 | ||||||||||||||||||||||||||||||||||||||||||||||||