Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running "df -k " on all platforms

Status
Not open for further replies.

tg2003

IS-IT--Management
Feb 6, 2003
270
IL
Hi,

I'm writing a wrapper that tells me the free space and percentage on some file systems.
I need it to work on all UNIX and Linux platforms.

Currently I'm thinking about a good regular expression that covers all platforms by using "df -k", but I'm not sure it's the best. It's a lot of work and testing.

Do you have some idea? a better one?

Thanks in advance!
 

Start with something like this:
Code:
#!/bin/ksh
>df.txt
for srv in server1 server2 server3 server4 server5
do
  echo "Server: $srv">>df.txt
  ssh $srv "df -k" >>df.txt
done
[3eyes]

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
It's an interesting problem; I had a similar challenge when I was writing my dispus script. Unfortunately platforms vary a lot, some keep the device and filesystem entries on the same line, some split them across two lines, some alter their behaviour in this respect with command-line switches (-P on Linux), or if the output is piped somewhere instead of to stdout (Solaris), some use different commands altogether (bdf on HP-UX), some report kilobytes by default, others require -k (Solaris), others require -kv (SCO), and some report nonsensical output with -kv (Solaris - note column headings!).

So, in short... you have your work cut out for you. I ended up writing platform specific handling for the weirder ones, and using some of my own code to join lines that were split across two rather than relying on their individual behaviour.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top