OT: posix sh problem

Mark Felder feld at feld.me
Thu Apr 4 12:32:33 UTC 2013


Hi all,

Hopefully someone here is much more clever than I am. I've run out of  
ideas on how to cleanly convert this chunk of ksh to posix sh. This is  
 from a BB/Hobbit/Xymon monitoring script for ZFS. I'd really like to have  
this working cleanly on FreeBSD without requiring any funky shells or  
using any temporary files.

The following is supposed to be able to loop through the output of  
multiple zpools reading one line at a time and each line item is set as a  
variable:


/sbin/zpool list -H | while read name size used avail cap dedup health  
altroot
do
   # do interesting things here
done

Unfortunately you can't pipe through read in posix sh. You also can't use  
process substitution: while read var1 var1 < <(/sbin/zpool list -H)


Any ideas are greatly appreciated. I know there's a python-based script  
floating on github but I cant guarantee every server will have python on  
it...




Source of script is here:  
http://en.wikibooks.org/wiki/System_Monitoring_with_Xymon/Other_Docs/HOWTO#Hobbit_Client_and_ZFS_monitoring


More information about the freebsd-questions mailing list