Problem with a script on a solaris 10 box

Hi Gurus
I have several SAN's in two different locations. I collect performance data and archive them. In one location the archiving script runs on a solaris 9 server and in the other on a solaris 10 server. But the script fails every day on the solaris 10 server with this

mes6=`/usr/bin/du -sk *${yesterday}* | /usr/bin/awk '{print $1}'`

I tried everything, even a redirect to a /tmp/output.txt to see what the output is. It is always 0

#!/usr/bin/sh

date=`date +'%Y%m%d'`
#yesterday=`expr $date - 1`
yesterday=`perl -e '@T=localtime(time-86400);printf("%02d%02d%02d",$T[5]+1900,$T[4]+1,$T[3])'`
dir=`date +'%m%y'`
host=`uname -n`

set -x
test ! -d $dir && mkdir $dir

cd /var/tmp/performance/controller
tar cvf controller_$yesterday.tar *${yesterday}*.txt
        mes1=`tar tvf controller_$yesterday.tar | wc -l`
/usr/bin/gzip *.tar
test ! -d archive/$dir && mkdir archive/$dir
/usr/bin/mv *.tar.gz archive/$dir/
        cd archive/$dir
        mes4=`du -sk *${yesterday}* | awk '{print $1}'`
cd /var/tmp/performance/controller
rm *${yesterday}*.txt

cd /var/tmp/performance/volume
tar cvf volume_$yesterday.tar *${yesterday}*.txt
        mes2=`tar tvf volume_$yesterday.tar | wc -l`
/usr/bin/gzip *.tar
test ! -d archive/$dir && mkdir archive/$dir
/usr/bin/mv *.tar.gz archive/$dir/
        cd archive/$dir
        mes5=`du -sk *${yesterday}* | awk '{print $1}'`
cd /var/tmp/performance/volume
rm *${yesterday}*.txt

cd /var/tmp/performance/array
tar cvf array_$yesterday.tar *${yesterday}*.txt
        mes3=`tar tvf array_$yesterday.tar | wc -l`
/usr/bin/gzip *.tar
test ! -d archive/$dir && mkdir archive/$dir
/usr/bin/mv *.tar.gz archive/$dir/
        cd archive/$dir
        mes6=`/usr/bin/du -sk *${yesterday}* | /usr/bin/awk '{print $1}'`
        echo $mes6 >> /tmp/output.txt
cd /var/tmp/performance/array
rm *${yesterday}*.txt

#send a webops message if too less files
if [ $mes1 -lt 720 ]; then
        /usr/local/bin/webopsmsg.pl -s 4 -m "Only $mes1 controller messages on $host, check script"
fi

if [ $mes2 -lt 720 ]; then
        /usr/local/bin/webopsmsg.pl -s 4 -m "Only $mes2 volume messages on $host, check script"
fi


if [ $mes3 -lt 720 ]; then
        /usr/local/bin/webopsmsg.pl -s 4 -m "Only $mes3 array messages on $host, check script"
fi

#send a webops message if .tar.gz is too small in size
if [ $mes4 -lt 250 ]; then
        /usr/local/bin/webopsmsg.pl -s 4 -m "Only $mes4 kb controller messages on $host, check script" 
fi

if [ $mes5 -lt 250 ]; then
        /usr/local/bin/webopsmsg.pl -s 4 -m "Only $mes5 kb volume messages on $host, check script"
fi

if [ $mes6 -lt 33 ]; then
        /usr/local/bin/webopsmsg.pl -s 4 -m "Only $mes6 kb array messages on $host, check script"
fi

So I have everyday webops messages and tickets.

Can you tell me whats wrong? Is it a problem with the solaris 10 server? On the solaris 9 server it runs without any probem.

Thanks in advance for your input.
gnom

if you're on Solaris, shouldn't you want to use nawk? Both are present on Solaris out of the box, of course, but nawk is a much richer utility.

Meanwhile, have you tried to manually break it down to see what the screen output is, or impose a 2>&1 (or 2>/tmp/output.txt) to follow the awk portion of the pipe? Assuming you do a manual cd to the archive/$dir and then run your command, what do you get?

cd /var/tmp/performance/array/archive/$dir 
/usr/bin/du -sk *20100511* |/usr/bin/awk '{print $1}' 

...or...

cd /var/tmp/performance/array/archive/$dir 
/usr/bin/du -sk *20100511* |/usr/bin/awk '{print $1}' 2>&1 

Thanks for your reply.
I run the script manually and it gave me the correct number back, 34.
I ran the script also via cron to see it the path is resolved
I ran the script with a variable and the variable had the correct value

I don't now what to do. Please help me

What does the screen output look like when you've run the set of commands from earlier post?

Oh, and since cron is also subject to shell environment...are you certain that your user logins are identical between your machines?

Hi
When I run the commands manually it doesn't give me an output. I have to make a

echo $mes6

Then it shows me the correct number.

But when I run the script every night and redirect the output to a file, it's always a 0

And yes the users are identical between the two locations.

Do you have an other idea?

Sorry...can't help without the terminal output.

In running the pared down commands, you're only cd-ing to the appropriate directory (ie, $dir = 052010) and then running during against all sub-contents named like *20100512*, the output of which is piped to awk. You wouldn't need to echo the variable since you wouldn't have been defining it.

Assuming that the directory(/ies) is there as expected, you should get an output. Maybe you just need to get a visual confirmation on the existence of the required directories?

You could also try short-circuiting the du output to not pipe into awk. Just do the cd and du steps to see what's there.