Problem with a script on a solaris 10 box


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem with a script on a solaris 10 box
# 1  
Old 05-12-2010
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
Code:
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

Code:
#!/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
# 2  
Old 05-12-2010
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?

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

...or...

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

# 3  
Old 05-12-2010
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
# 4  
Old 05-12-2010
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?
# 5  
Old 05-12-2010
Question

Hi
When I run the commands manually it doesn't give me an output. I have to make a
Code:
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?
# 6  
Old 05-12-2010
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.

Last edited by curleb; 05-12-2010 at 11:45 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Notify when the script run(hourly)on my jump-box only when there is a failure on my remote-box

Team, Presently I have a script, which i have set up cron on one of my Jump-boxes,and gives me the output on every hourly basis,fetching the data from the remote machine.Basically it gives me the list of all active users logged and its count once we execute the script.Here the count is... (6 Replies)
Discussion started by: whizkidash
6 Replies

2. Shell Programming and Scripting

Need a script to add mutiple printers in solaris box

Hi , i need to configure around 80 printers in a server. can someone please help me with the script. i have a file that has printer name and its ip. like. printer1 1.1.1.1 printer2 0.0.0.0 and so on.. can some one please help me to do it via script. i am using solaris 10 ... (0 Replies)
Discussion started by: chidori
0 Replies

3. Solaris

E1 on Solaris box

hi, can someone please guide me if there is any special hardware to use when we need to terminate an E1/T1 link on a Solaris10 box. I have a number of boxes and these all are located at longer distances. the only connectivity is the E1 links between these far location locations. Would it be... (0 Replies)
Discussion started by: busyboy
0 Replies

4. Shell Programming and Scripting

ftp file starting with particular name on Windows box to Unix box using shell script

Hello all ! I'm trying to write a shell script (bash) to ftp a file starting with particular name like "Latest_" that is present on a Windows box to UNIX server. Basically I want to set this script in the cron so that daily the new build that is posted on the Windows box can be downloaded to the... (2 Replies)
Discussion started by: vijayb4u83
2 Replies

5. Shell Programming and Scripting

sftp script needed for solaris box

Hi , I have a solaris box through which i need to connect to ATM's and pull files using sftp. I did same type of scripting using ftp before but no sftp.The problem now i am facing is, i want to put the password along with this sftp (non-interactive) script. Unfortunately there is no... (3 Replies)
Discussion started by: Renjesh
3 Replies

6. Shell Programming and Scripting

calling a unix script in one box from another box

i have a unix script which is available in a box say box1 i want this script to be run in box box2 and put the output file in box2 what is the procedure to execute this script in box2 i will call the script in box1 using cybermation (1 Reply)
Discussion started by: trichyselva
1 Replies

7. Shell Programming and Scripting

Box A's perl script calling box B's shell script

Hi all, i have a perl script one server. I am running a cronjob to execute my perl script. #! /usr/bin/perl ... ... ... #call a shell script on another server How can i accomplish #? Do i have to issue a system (" ssh -l username server | shellscript.sh") in my shell script? or is there a... (1 Reply)
Discussion started by: new2ss
1 Replies

8. UNIX for Dummies Questions & Answers

difference between AIX box and Sun Solaris box

Hi, I need a clarification. Is there any difference between AIX box and Sun Solaris box? The bzip command with -c option works in AIX box and the same does not work in Sun Solaris box. Can anyone please explain if there is an implementation difference in both these boxes for the shell... (1 Reply)
Discussion started by: nisha4680
1 Replies

9. Shell Programming and Scripting

Script to Reboot a linux box from a windows box

HI All, I need a script to reboot a linux box from a windows box. The script needs to run automatically whenever a sitescope alerts with an error message. Have searched for this in the forums, but could not get something relative. Pls. let me know the various alternatives we have to do... (2 Replies)
Discussion started by: Crazy_murli
2 Replies

10. Solaris

Error on Solaris box

We are getting the following error: warning: pm: Can't set power level of TSI, gfxp to level 0 The machine is running Solaris 8. I think it is a SUn 220R box. Any ideas what this means? (2 Replies)
Discussion started by: hshapiro
2 Replies
Login or Register to Ask a Question