DOlson Posted September 6, 2003 Report Share Posted September 6, 2003 Here is a simple script I wrote today while setting up my sisters' computer with Debian. What it does is checks the freespace on a given partition, tells how much is left, and what percentage is in use. It should be good enough for them. I know a few times I wanted something simple like this without opening a terminal (I have a commandline at the top of my screen, so it's easy to run a command) or without running a full-blown app like kdf. Here's a screenshot: Here's the script: #!/bin/sh FREE=`df -h | grep hda3 | awk '{ print $4 }'` USED=`df -h | grep hda3 | awk '{ print $5 }'` zenity --info --text="You have $FREE free, $USED of your space is in use." --title="Disk Usage Report" That script will show the space of partition hda3, so modify it to your own delight. :) You'll need zenity installed too. Quote Link to comment Share on other sites More sharing options...
bvc Posted September 6, 2003 Report Share Posted September 6, 2003 Thanks! On mandrake line 4: zenity: command not found urpmi zenity no package named zenity http://speakeasy.rpmfind.net/linux/rpm2htm...ubmit=Search+... http://rpm.pbone.net/index.php3?idpl=39658...k.i586.rpm.html I used; http://speakeasy.rpmfind.net//linux/RPM/ma...-1mdk.i586.html Quote Link to comment Share on other sites More sharing options...
DOlson Posted September 6, 2003 Author Report Share Posted September 6, 2003 To my knowledge, there is no program called GDF, so I did this: save that script as /usr/local/bin/gdf chmod +x /usr/local/bin/gdf Now I can just run it anytime by typing gdf. I meant to write this script like a year ago, but yeah, here it is now. :) Quote Link to comment Share on other sites More sharing options...
bvc Posted September 6, 2003 Report Share Posted September 6, 2003 I just vi fr6.sh >copy and pasted the script and saved >opened a terminal and ran fr6.sh, and it worked. fr=free 6=hda6 Then I did the same for 2 other partitions, so I have a fr6.sh, fr8.sh, and fr9.sh Any idea how the make the script read and display more than one partition, and show the label? Quote Link to comment Share on other sites More sharing options...
Germ Posted September 6, 2003 Report Share Posted September 6, 2003 Nice one. Thanks. :) Quote Link to comment Share on other sites More sharing options...
SoulSe Posted September 6, 2003 Report Share Posted September 6, 2003 Sweet. 8) Quote Link to comment Share on other sites More sharing options...
DOlson Posted September 7, 2003 Author Report Share Posted September 7, 2003 Any idea how the make the script read and display more than one partition, and show the label? Sure: #!/bin/sh FREE1=`df -h | grep hda3 | awk '{ print $4 }'` USED1=`df -h | grep hda3 | awk '{ print $5 }'` NAME1=Home FREE2=`df -h | grep hda1 | awk '{ print $4 }'` USED2=`df -h | grep hda1 | awk '{ print $5 }'` NAME2=Root FREE3=`df -h | grep hdc2 | awk '{ print $4 }'` USED3=`df -h | grep hdc2 | awk '{ print $5 }'` NAME3=Backup zenity --info --title="Disk Usage Report" --text=" You have $FREE1 free space on $NAME1, $USED1 is in use.n You have $FREE2 free space on $NAME2, $USED2 is in use.n You have $FREE3 free space on $NAME3, $USED3 is in use." Now, just edit each thing how you want it, and you'll get a screenshot like this: EDIT: I noticed just now that you mentioned a label... Well, as you can see, the script allows you to put anything you like as the label, but if you meant some other label, then I don't know. It can be done, but I don't see any labels in my output of df. Quote Link to comment Share on other sites More sharing options...
bvc Posted September 7, 2003 Report Share Posted September 7, 2003 That's what I meant. Thank you! It's great! Quote Link to comment Share on other sites More sharing options...
william Posted September 7, 2003 Report Share Posted September 7, 2003 I got it to work but despite of using the last script (with 3 spaces), when typing gdf.sh I got the disk usage report window but with a simple line reporting the 3 spaces information, like this: You have 2.0G free space on Home, 61% is in use./nYou have 3.8G free space on Windows, 61&is in use./nYou have 2.3G free, ...... How to break it in 3 lines, as you've gotten, one line to each space? Could it be a typo? Quote Link to comment Share on other sites More sharing options...
DOlson Posted September 7, 2003 Author Report Share Posted September 7, 2003 Yes, typo it is. You put /n when it should say n. Quote Link to comment Share on other sites More sharing options...
william Posted September 7, 2003 Report Share Posted September 7, 2003 You have 2.0G free space on Home, 61% is in use./nYou have 3.8G free space on Windows, 61&is in use./nYou have 2.3G free, ...... Sorry Dolson, read instead /. I've just copied and paste your script to gedit. It looks like yours. zenity --info --title="Disk Usage Report" --text="You have $FREE1 free space on $NAME1, $USED1 is in use. n You have $FREE2 free space on $NAME2, $USED2 is in use. n You have $FREE3 free space on $NAME3, $USED3 is in use." Quote Link to comment Share on other sites More sharing options...
DOlson Posted September 7, 2003 Author Report Share Posted September 7, 2003 You copied and pasted my script, and it doesn't work? Why does it work for everyone else? Maybe you have an old version of zenity? I don't know... If the slashes were wrong, then that would have explained it. Quote Link to comment Share on other sites More sharing options...
SoulSe Posted September 7, 2003 Report Share Posted September 7, 2003 That is awesome. You can, of course, just use Gnome system monitor to get the same info... Quote Link to comment Share on other sites More sharing options...
DOlson Posted September 7, 2003 Author Report Share Posted September 7, 2003 That is awesome. You can, of course, just use Gnome system monitor to get the same info... Yes, and you can also use the df command. But that's not the point. Some people (ie: my sisters) might like to know how much space is free without knowing much about Linux... This is why I wrote this. Quote Link to comment Share on other sites More sharing options...
gregor Posted September 7, 2003 Report Share Posted September 7, 2003 I used;http://speakeasy.rpmfind.net//linux/RPM/ma...-1mdk.i586.html You could also add contrib, plf & texstar media: http://plf.zarb.org/~nanardon/ From Zenity README: If you understand, things are just as they are. If you don't understand, things are just as they are. :wink: Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.