Solved

Howto store available drive space to a variable for script evaluation

Posted on 2002-04-30
3
214 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
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…
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.

691 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