1752402 Members
5623 Online
108788 Solutions
New Discussion юеВ

Scripting Question

 
SOLVED
Go to solution
frederick hannah
Super Advisor

Scripting Question

I use "wc -l" with a command to give me the number of lines of application processes. If that line is less than a certain amount, I know the applicatio has a problem. How can I feed this number into a script that will act upon the number of lines? I know the -gt or -lt conditions are used, but as yet I dont how to make this work.
4 REPLIES 4
Steven Schweda
Honored Contributor

Re: Scripting Question

Do you want a fish, or do you want to learn
how to catch a fish?

You might start by asking Google (or any
other Web search engine) to look for keywords
like, say:

shell script gt lt

That should find thousands of helpful
explanations and examples.
Steven Schweda
Honored Contributor
Solution

Re: Scripting Question

> You might start [...]

Or:
shell script tutorial
or:
shell script primer
frederick hannah
Super Advisor

Re: Scripting Question

I prefer to crab or shrimp to be honest. I am using Google and I think I am getting close to an answer. Thanks
klb
Valued Contributor

Re: Scripting Question

BASE=/home/workarea
LOW_LIMIT=10 #lines
OUTFILE=/tmp/tmp_$$
PROG_LOG=$BASE/logs/plog.txt

tee -a $PROG_LOG \
| wc -l \
>$OUTFILE 2>&1

# exit if error above
status=$?
if [ $status -ne 0 ];then
echo "fail, done"
exit;
fi
CURRENT_LINES=`cat $OUTFILE`

if [ $CURRENT_LINES -lt $LOW_LIMIT ];then
#go do something about it
else
echo "success"
fi