How to evaluate data returned to specify actions??...

Hello:

I have written a small applescript which requests the ip address of a unit to login to and request an df -h command, which in exchange will return the Volumes mounted and their usage percentage.

example:

spawn ssh admin@10.1.0.123 df -h
Password:
Filesystem Size Used Avail Capacity Mounted on
/dev/disk0s3 15Gi 9.7Gi 5.0Gi 66% /
devfs 108Ki 108Ki 0Bi 100% /dev
fdesc 1.0Ki 1.0Ki 0Bi 100% /dev
map -hosts 0Bi 0Bi 0Bi 100% /net
map auto_home 0Bi 0Bi 0Bi 100% /home
/dev/disk0s2 15Gi 8.6Gi 6.3Gi 58% /Volumes/Rescue
/dev/disk0s4 26Gi 7.7Gi 18Gi 31% /Volumes/Vault
/dev/disk1s2 51Gi 33Gi 18Gi 65% /Volumes/MediaVault

I am interested in using this data to define actions…

first find “/dev/disk0s3/” and if its capacity is at 100% run a shell script
then find “/dev/disk0s2/” if it is not available run a shell script
then find “/dev/disk0s4/” if it is not available run a shell script

lastly… Alert the client what were the actions taken as an “Alert Message”.

So far… I have everything needed up to the point of obtaining the df -h command response, but I cannot figure out how to manipulate the returned data to perform further commands…

Please, if any ideas, I would really appreciate your points of view.

HT

Hi,

a point to start:
the shell script line filters all lines containing disk and prints out the identifier, percent and name information


set info to paragraphs of (do shell script "df -h | awk '/disk/ {print $1,$5,$6}'")
set {TID, text item delimiters} to {text item delimiters, " "}
set startVolume to item 1 of info
set percentOfStartVolume to (text 1 thru -2 of text item 2 of startVolume) as integer
set text item delimiters to TID