Re: [wmii] 20071003 snapshot config question

From: Uriel <uriel99_AT_gmail.com>
Date: Mon, 8 Oct 2007 18:41:44 +0200

If one is going to use rc, it is worth reading this paper:
http://doc.cat-v.org/plan_9/4th_edition/papers/rc

uriel

On 10/8/07, sqweek <sqweek_AT_gmail.com> wrote:
> On 10/8/07, Dewey Hylton <dewey-wmii_AT_hyltown.com> wrote:
> > Quoting sqweek <sqweek_AT_gmail.com>:
> > > On 10/8/07, Dewey Hylton <dewey-wmii_AT_hyltown.com> wrote:
> > the first one seems to have worked like a champ, but the second one is still
> > problematic. obviously, i didn't understand the rc.wmii syntax initially and
> > apparently still don't.
> >
> > here's my last attempt (trying to follow the great info from sqweek):
> > fn status {
> > load=`{uptime | sed 's/.*://; s/,//g'}
> > export=`{df -h /export|awk 'END {print "Export: "$3"/"$1"/"$4}'}
> > root=`{df -h /|awk 'END {print "Root: "$3"/"$1"/"$4}'}
> > status=`{date}' || '`{acpi}' || '$root || '$export || '$load
> > echo -n $status
> > }
>
> Right, I should have tested before I posted. rc uses ^ as a
> concatenation operator. A lot of places you can elide the ^ and rc
> will insert it itself (see Free Carets in rc(1)), but apparently after
> a `{} isn't one of them, so you need to do it explicitly as in
> `{date}^' || '`{acpi}^...
> However, there's another problem. `{} evaluates to a list (based on
> the whitespace seperated output of the command), and concatenating a
> list in rc is similar to brace expansion in POSIX shells. ie:
>
> ; echo a^(b c d)
> ab ac ad
>
> So, we need to flatten the lists returned by `{date} and `{acpi}
> before concatenating them, and I'm going to have to lookup the man
> page to see if I can work out how to do that on an anonymous list or
> whether we need to use a variable...
> Ah, of course, `{} results in a list delimited by $ifs, not whitespace. So:
>
> ifs='
> ' {
> status=`{date}^' || '`{acpi}^' || '$root' || '$export' || '$load
> echo -n $status
> }
>
> But then, this still hase problems since $root/$export/$load are
> probably also lists :D
> Also, status is not a great variable name to use because rc uses it
> (similar to $? in POSIX sh). Anyway, simplest way all round is
> probably just:
>
> date=`{date}
> acpi=`{acpi}
> echo -n $"date' || '$"acpi' || '$"root' || '$"export' || '$"load
>
> $" flattens the lists into strings.
> -sqweek
>
>
Received on Mon Oct 08 2007 - 18:41:47 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 16:29:12 UTC