Solved

Howto store available drive space to a variable for script evaluation

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now