The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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 12:17 PM
Put fails during FTP prakash.kudreka UNIX for Advanced & Expert Users 2 11-15-2007 05:14 AM
SCP fails sometimes vipinc AIX 10 07-18-2007 02:38 AM
Shell Script fails with "can't connect to client" sseenu79 HP-UX 2 12-20-2006 10:47 AM
System Fails nikk UNIX for Advanced & Expert Users 2 07-07-2004 09:05 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-09-2006
JStone JStone is offline
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.
  #2 (permalink)  
Old 08-09-2006
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
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
  #3 (permalink)  
Old 08-09-2006
JStone JStone is offline
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?
  #4 (permalink)  
Old 08-09-2006
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
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.
  #5 (permalink)  
Old 08-09-2006
JStone JStone is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 15
Hi, Thanks for your suggestion. I will do that.
  #6 (permalink)  
Old 08-09-2006
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,414
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 04:20 AM..
  #7 (permalink)  
Old 08-09-2006
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
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
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:27 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0