Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 04 Apr 2013 07:32:30 -0500
From:      "Mark Felder" <feld@feld.me>
To:        freebsd-questions@freebsd.org
Subject:   OT: posix sh problem
Message-ID:  <op.wu0nsgsf34t2sn@tech304.office.supranet.net>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?op.wu0nsgsf34t2sn>