Solved

Howto store available drive space to a variable for script evaluation

Posted on 2002-04-30
3
211 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
nodeip 9 86
Linux: disable vim auto-comment 7 136
Searching File Names and Eliminating Duplicates in Linux 4 74
Field name with special character (Ñ) in Oracle 11 80
Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
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 how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

789 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