Path: utzoo!attcan!uunet!ogicse!schaefer From: schaefer@ogicse.ogi.edu (Barton E. Schaefer) Newsgroups: comp.mail.mush Subject: Re: Problem setting headers to output from shell commands Message-ID: <12320@ogicse.ogi.edu> Date: 21 Sep 90 17:41:11 GMT References: <1990Sep21.091000.11589@ibmpcug.co.uk> Organization: Oregon Graduate Institute (formerly OGC), Beaverton, OR Lines: 63 In article <1990Sep21.091000.11589@ibmpcug.co.uk> dylan@ibmpcug.co.uk (Matthew Farwell) writes: } Ok. This may seem a silly question, but I have RTFM'd, and I can't see } an easy + simplistic answer. } } I want to include the output from a shell command in a header. That's because mush doesn't support a text-substitution `command` mechanism. Backquoted commands substitute message lists, just as "pipes" in mush pass message lists rather than text. } Say I wanted to produce a header like } } my_hdr X-My-Date: `sh date` } } How would I go about it? That one is fairly easy, actually: cmd sh_hdr "sh 'echo my_hdr \!:1 ` \!:2-$ ` > $tmpdir/h$$'; source $tmpdir/h$$" this of course assumes you have set tmpdir somewhere, use /tmp if not. You can fool with the quoting to get $tmpdir expanded at execute time rather than at cmd-definition time if you want. Usage example: sh_hdr X-My-Date: date The major drawback of this is that you can't use it in a .mushrc file (because the \! positional references are not recognized when sourcing a file, to avoid complaints about alias addresses having ! characters). In the .mushrc, you'll have to perform the expansion yourself, e.g. # Generate an extra date header if is_sending sh "echo my_hdr X-My-Date: `date` > $tmpdir/h$$"; source $tmpdir/h$$ endif Rich Burridge, are you reading this? Why didn't I think of this when you were trying to integrate mush with faces? Oh, well .... } p.s. `date` is only used as an example. I want a generic way of doing things. The above is as close to generic as it gets at the moment. I posted a mush script called "bq" (for backquote) a while ago which does this in a slightly more generalized manner, but I don't have a copy handy. You could also try: cmd bq "sh 'echo \!* > $tmpdir/bq$$'; source $tmpdir/bq$$" which would be used like bq my_hdr X-My-Date: `date` bq set hostname=`hostname` However, that would only work for very simple commands because of quoting problems. For example, bq set date=`date` would not work; using my current date as an example, it would set date to "Fri", and create variables named "Sep", "21", "10:35:26", "PDT", and "1990", which is clearly not what you want. ;-} -- Bart Schaefer schaefer@cse.ogi.edu