The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
#!/bin/sh script fails at StringA | tr "[x]" "[y]" by_tg UNIX for Dummies Questions & Answers 3 02-22-2008 09:17 AM
Put fails during FTP prakash.kudreka UNIX for Advanced & Expert Users 2 11-15-2007 02:14 AM
SCP fails sometimes vipinc AIX 10 07-17-2007 11:38 PM
Shell Script fails with "can't connect to client" sseenu79 HP-UX 2 12-20-2006 07:47 AM
System Fails nikk UNIX for Advanced & Expert Users 2 07-07-2004 06:05 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 08-08-2006
Registered User
 

Join Date: Nov 2005
Posts: 15
Script fails

Hi,

I am trying to install a package on solaris and one of the packaging scripts fail unexpectedly. There is a script called "checkinstall" which checks for the /opt space and aborts the installation if /opt is less than 100MB. In my case, even if /opt has enoguh space, the script fails.

This is my script

REQUIRED_SAPCE="100000"
AVAILABLE_SPACE=`df -k /opt | grep -v "avail" | awk '{print $4}'`
if [ "$AVAILABLE_SPACE" -lt "$REQUIRED_SPACE" ]
then
echo "Space available in /opt is ${AVAILABLE_SPACE}KB. ${REQUIRED_SPACE}KB required"
exit 1
fi

The baffling thing here is, we get an error message like this and the installation gets aborted.

Space available in /opt is 450000KB. 100000KB required.

So, obviously /opt has enough space. Then why this gets into the if loop unnecessarily. What could be the problem? Any ideas??

This works fine on our test machines and the issue is happening at one of the customer's machines.

Thanks in advance,
JStone.
Reply With Quote
Forum Sponsor
  #2  
Old 08-08-2006
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,698
Quote:
Originally Posted by JStone
REQUIRED_SAPCE="100000"
AVAILABLE_SPACE=`df -k /opt | grep -v "avail" | awk '{print $4}'`
if [ "$AVAILABLE_SPACE" -lt "$REQUIRED_SPACE" ]
then
echo "Space available in /opt is ${AVAILABLE_SPACE}KB. ${REQUIRED_SPACE}KB required"
exit 1
fi
I see a SAPCE vs SPACE. Your grep options should be grep -vi instead of grep -v

Try this.
Code:
REQUIRED_SPACE=100000
AVAILABLE_SPACE=$(df -k /opt | grep -vi "avail" | awk '{print $4}')
if [ $AVAILABLE_SPACE -lt $REQUIRED_SPACE ]  
then
  echo "Space available in /opt is ${AVAILABLE_SPACE}KB.  ${REQUIRED_SPACE}KB required"
  exit 1
fi
Reply With Quote
  #3  
Old 08-08-2006
Registered User
 

Join Date: Nov 2005
Posts: 15
Hi, Thanks for the reply. That was a typo by mistake. I iterate that I have installed the package successfully in our test enviroment so many times, I am just trying to figure out the reason for the failure on the customer's machine. Could that be something related to their machine settings?? By the way, what is the shell used during an install?
Reply With Quote
  #4  
Old 08-08-2006
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,698
The shell used during an install will usually depend on the shebang that is present in the installation script.

Try the following

Code:
set -x
./run your script
set +x
You should be able to see the commmands being carried out. That should help you. Unless you get access to the customer's box or ask the customer to run the above, I dont think there is a way to debug this.
Reply With Quote
  #5  
Old 08-08-2006
Registered User
 

Join Date: Nov 2005
Posts: 15
Hi, Thanks for your suggestion. I will do that.
Reply With Quote
  #6  
Old 08-09-2006
aigles's Avatar
Registered User
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,212
With AIX, the df command output shows the free space in the field 3 and the field header is'nt 'avail' but 'Free'.
Code:
$ df -k /opt
Filesystem    1024-blocks      Free %Used    Iused %Iused Mounted on
/dev/hd4           163840     32724   81%     1847     3% /
The -P option (Displays information on the file system in POSIX portable format) gives output compatible with your script :
Code:
$ df -kP /opt
Filesystem    1024-blocks      Used Available Capacity Mounted on
/dev/hd4           163840    131116     32724      81% /
Jean-Pierre.

Last edited by aigles; 08-09-2006 at 01:20 AM.
Reply With Quote
  #7  
Old 08-09-2006
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,610
if the disk space for a single mount is determined, no to check for the word whether it is avail or free ...

either way the disk space with a -k option for a single mount would be displayed only in the following format

header
values for the single mount


now eliminate the first line that is process only the second line
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:11 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0