Solved

Howto store available drive space to a variable for script evaluation

Posted on 2002-04-30
3
209 Views
Last Modified: 2010-04-21
Question:  How can I capture available diskspace information in a script and depending on the value perform actions?

Ideally I'd like a working example of the following pseudo-code:

Set AvailSpace = awk/sed/parse and store to var number
if $AvailSpace > 333800 then
  echo OK
else
  echo abort
endif

Some jobs are failing due to insufficient drivespace.  
This is an old process running on an old box with operating system of:

SunOS Release 4.1.3

I've got a partial clue on how to manually see the value:

JoeUser/usr/local% df | tail -1
/dev/sd2a             963662  581656  333823    64%    /work

I'm just not sure how to assign the value '333823' to a variable for
comparison.

Any thoughts would be appreciated.
Thanks!
0
Comment
Question by:jhawklyn
  • 2
3 Comments
 
LVL 38

Expert Comment

by:yuzh
ID: 6982423
In your script you can do: (asume that you are using sh/ksh)


FREESPACE=`df -k | grep device-name | awk '{print $4}'`

   if you want to use device-name a command line arg, using $1 instead of the device-name.

   Cheers!

======
yuzh
0
 
LVL 38

Accepted Solution

by:
yuzh earned 50 total points
ID: 6982698
ok you are a csh/tcsh user,
In your script should look like the followings:

     Set AvailSpace =  `df | tail -1 | awk '{print $4}'`

0
 

Author Comment

by:jhawklyn
ID: 6983654
Thanks!  Exactly what I was looking for.   Now I know a little more about awk.   Should help in some other areas.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Move nodes from one TSM to another. 3 73
Where to get php 5.6 for AIX 7.1? 5 98
Oracle Finace 3 76
Best way to split and output to csv in bash 2 64
In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question