Script fails


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script fails
# 1  
Old 08-09-2006
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  
Old 08-09-2006
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  
Old 08-09-2006
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  
Old 08-09-2006
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  
Old 08-09-2006
Hi, Thanks for your suggestion. I will do that.
# 6  
Old 08-09-2006
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 05:20 AM..
# 7  
Old 08-09-2006
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

./ignite.sh script fails after 5 seconds

Hello, I am trying to run a make_net_recovery Ignite for a server in a 2 node cluster . But I do get some issues. VG "/dev/vg59" is not defined in file "/etc/lvmtab". VG "/dev/vg59" is not defined in file "/etc/lvmtab_p". save_config: Error - vg00 not in the volume/disk group ERROR: ... (0 Replies)
Discussion started by: velde_van_der_a
0 Replies

2. Shell Programming and Scripting

Script execution fails

hi, i am trying to run this script, getting below error, can some one help me in this Error: -bash: on_failure.sh: line 23: syntax error: unexpected end of file ======================================================== # CHANGE HISTORY # # YYYYMMDD Change by Desription # --------... (2 Replies)
Discussion started by: szs
2 Replies

3. Shell Programming and Scripting

Execute shell script even if the first script fails

All, I executing a perl script and shell script from a master shell script. i will execute the perl script first and have to execute the shell script after the completion of perl execution. Below is the code i use for it, script_root='/dev/scripts' /usr/bin/perl -S $script_root/test.pl;... (5 Replies)
Discussion started by: vel4ever
5 Replies

4. Shell Programming and Scripting

Script fails with ORA-20000 when run with su

Hi, I have a ksh script that runs as root ans issues several commands as a user differente from root as 'su <user> -c "command" ' . It works fine except for one step where the command executes sql statements. That command fails with ORA-20000. Now the strangest thing, if I place a read command... (5 Replies)
Discussion started by: naf
5 Replies

5. Shell Programming and Scripting

Stop execution of script if some condition fails

After my if condtion give rusult true then script should stop execution. Please advice...Thnaks in advance (1 Reply)
Discussion started by: vivek1489
1 Replies

6. Shell Programming and Scripting

crontab fails to run script

OS is Ubuntu 8.04.3. When I run the command: /usr/bin/syslogMailer < /etc/syslog.pipes/criticalMessagesFrom a bash shell it works and i receive an email as per the script however when run from crontab it does not work. Can anyone explain why and how to fix it? /usr/bin/syslogMailer... (4 Replies)
Discussion started by: jelloir
4 Replies

7. Shell Programming and Scripting

log file when the script fails !

i have a script that will retrive some info from database. The script is working fine but i have to add new feature in it when the script fails or retrive null result it should reflect in the log file. below the script AMR_Inactive.sh while read i do connect1=`sqlplus -silent... (3 Replies)
Discussion started by: ali560045
3 Replies

8. Shell Programming and Scripting

why shell script fails?

hi , i m trying to run a shell script automatically , some time it works fine but some time it fails , what could be the problem . If anybody have an idea about this problem then reply . Thanks in advacne (4 Replies)
Discussion started by: tahir23
4 Replies

9. UNIX for Advanced & Expert Users

why script fails sometime?

Hi, I am trying to run a shell script on solaris,some time it works fine and some times it fails unexpectedly. There is a script called "autostart.sh" which automatically starts the Application server but some times the script fails to strat the application server. can anyone tell me what... (10 Replies)
Discussion started by: tahir23
10 Replies

10. Shell Programming and Scripting

why shell script fails

hi .. I have automate some process on unix through sehll script . but i don't know there is some problem in scripts, some time shell script works and some time it fails. so my query is that "Why shell script fails some times?" thanks (4 Replies)
Discussion started by: tahir23
4 Replies
Login or Register to Ask a Question