gringomike
Technical User
Hi all,
Does anybody have any idea why this script doesn't work? I'm trying to have it report on rogue processes (PID's which return NULL when $VAR2 is executed).
VAR1=`ps -ef |grep VAR2 |grep -v grep |awk '{print $2}'`
for VAR3 in $VAR1
do
COUNT=`ptree $VAR3 |wc -l`
VAR2=`ps -ef |grep $VAR3 |awk '{print $12}'`
if (($COUNT > 2))
then
echo "$FILE is an active process."
else
echo "$VAR2 with process ID $VAR3 is a rogue process."
fi
done
The output is detailed below;
with process ID 20437 is a rogue process.
./script.ksh: 2: not found
TESTI with process ID 28249 is a rogue process.
./script.ksh: 2: not found
TESTN with process ID 28178 is a rogue process.
./script.ksh: 6: not found
with process ID 20473 is a rogue process.
./script.ksh: 6: not found
with process ID 20492 is a rogue process.
./script.ksh: 6: not found
It reports OK when it displays the following line;
TESTN with process ID 28178 is a rogue process.
However it should report the process as being "active" when it displays;
with process ID 20492 is a rogue process.
I also don't understand where these erros are coming from;
./script.ksh: 6: not found AND ./script.ksh: 2: not found
I'm almost sure it's a syntax problem somewhere but I have no idea where!
I hope this makes sense.
Thanks for your help in advance
GM
Does anybody have any idea why this script doesn't work? I'm trying to have it report on rogue processes (PID's which return NULL when $VAR2 is executed).
VAR1=`ps -ef |grep VAR2 |grep -v grep |awk '{print $2}'`
for VAR3 in $VAR1
do
COUNT=`ptree $VAR3 |wc -l`
VAR2=`ps -ef |grep $VAR3 |awk '{print $12}'`
if (($COUNT > 2))
then
echo "$FILE is an active process."
else
echo "$VAR2 with process ID $VAR3 is a rogue process."
fi
done
The output is detailed below;
with process ID 20437 is a rogue process.
./script.ksh: 2: not found
TESTI with process ID 28249 is a rogue process.
./script.ksh: 2: not found
TESTN with process ID 28178 is a rogue process.
./script.ksh: 6: not found
with process ID 20473 is a rogue process.
./script.ksh: 6: not found
with process ID 20492 is a rogue process.
./script.ksh: 6: not found
It reports OK when it displays the following line;
TESTN with process ID 28178 is a rogue process.
However it should report the process as being "active" when it displays;
with process ID 20492 is a rogue process.
I also don't understand where these erros are coming from;
./script.ksh: 6: not found AND ./script.ksh: 2: not found
I'm almost sure it's a syntax problem somewhere but I have no idea where!
I hope this makes sense.
Thanks for your help in advance
GM