Date: Thu, 04 Apr 2013 10:11:35 -0500 From: "Mark Felder" <feld@feld.me> To: "Teske, Devin" <Devin.Teske@fisglobal.com>, "Devin Teske" <dteske@freebsd.org> Cc: "<freebsd-questions@freebsd.org>" <freebsd-questions@freebsd.org> Subject: Re: OT: posix sh problem Message-ID: <op.wu0u5lpq34t2sn@tech304.office.supranet.net> In-Reply-To: <13CA24D6AB415D428143D44749F57D7201EF2411@ltcfiswmsgmb21> References: <op.wu0nsgsf34t2sn@tech304.office.supranet.net> <13CA24D6AB415D428143D44749F57D7201EF2411@ltcfiswmsgmb21>
next in thread | previous in thread | raw e-mail | index | archive | help
Sorry, my email client did something weird with collapsing and I didn't = = see you mention that it appeared to be working for you. On Thu, 04 Apr 2013 08:54:30 -0500, Teske, Devin = <Devin.Teske@fisglobal.com> wrote: > The only things I saw that needed changing to go from ksh to /bin/sh = > were: > if [ =E2=80=A6 =3D=3D =E2=80=A6 ]; then > Needs to be > if [ =E2=80=A6 =3D =E2=80=A6 ]; then > And optionally, a style nit would be to convert back-tick pairs into = > nestable $(=E2=80=A6) syntax. For example, change: > cap=3D`=E2=80=A6` > to instead: > cap=3D$(=E2=80=A6) > Oh and of course, the HTML should go away since you're making a = > command-line tool and not a BB/Hobbit/Xymon module. I actually will be using this with Xymon at work. I did fix the =3D=3D a= nd = style nit when I went over this script I'm still having a problem. When = I = started debugging this last night $STRING led me to believe the pipe int= o = read wasn't working right. At the bottom of the script I added echo in = front of the "$BB $BBDISP...." line. My output is this: # sh zfs_xymon.sh status .zfs green Thu Apr 4 09:59:36 CDT 2013 zfs - health: okay - = capacity: okay <table border=3D0 cellpadding=3D10><tr><th></th><th>Zpool= = Name</th><th>Status</th><th>Capacity</th></tr> </table><br><br>all pools= = are healthy Where are the other parts of the table showing each zpool? Those are jus= t = the headers. If you sh -x you'll see it flow like this: + read name size used avail cap depup health altroot + STRING=3D'<table border=3D0 cellpadding=3D10><tr><th></th><th>Zpool = Name</th><th>Status</th><th>Capacity</th></tr> </table><br><br>' + /sbin/zpool status -xv It's like everything between do ... done never happened? If you put echo= = in front of line 60 you DO get output: # sh zfs_xymon.sh STRING=3D<table border=3D0 cellpadding=3D10><tr><th></th><th>Zpool = Name</th><th>Status</th><th>Capacity</th></tr> = <tr><td>&green</td><td>tank</td><td>ONLINE</td><td>48</td></tr> status .zfs green Thu Apr 4 10:07:30 CDT 2013 zfs - health: okay - = capacity: okay <table border=3D0 cellpadding=3D10><tr><th></th><th>Zpool= = Name</th><th>Status</th><th>Capacity</th></tr> </table><br><br>all pools= = are healthy But as you can see, everything in that do ... done is disappearing. = According to Rich's Posix sh tricks site it explains that the things to = = the right of that pipe are completed in a subprocess. The updates it mak= es = to STRING never make it out so it can be used in the rest of the script.= Do you see what I mean now? :(
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?op.wu0u5lpq34t2sn>