9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] sam -d reading from stdin?
@ 2004-01-31 12:40 Matthias Teege
  2004-01-31 13:07 ` David Presotto
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Matthias Teege @ 2004-01-31 12:40 UTC (permalink / raw)
  To: 9fans

Moin,

I use the following in pipefrom to get the
content of the Reply-To header from an
outgoing Email.

cat > $TMP
replyto=`{echo ', x/(.+\n)+/ g/^[Rr]eply-[Tt]o:.*/ p' | sam -d $TMP >[2] /dev/null | tr A-Z a-z | grep reply-to | sed 's/reply-to: *//'}

Is there any way to avoid the creation of
a temporary file? Can I read from stdin
with sam -d?

Second question. Is there any way to make
g/^[Rr]eply-[Tt]o:.*/ case insensitive
without using [Rr] constructs?

Matthias


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] sam -d reading from stdin?
  2004-01-31 12:40 [9fans] sam -d reading from stdin? Matthias Teege
@ 2004-01-31 13:07 ` David Presotto
  2004-02-01  0:18 ` Geoff Collyer
  2004-02-01  3:31 ` boyd, rounin
  2 siblings, 0 replies; 7+ messages in thread
From: David Presotto @ 2004-01-31 13:07 UTC (permalink / raw)
  To: 9fans

How about

	tee /fd/2 |[2] {tr A-Z a-z | sed -n 's/^reply-to: *//p
/^$/q'} >/env/x

Well, its a temp file but just the environmnt one you had anyways.  You can't use
$x later in the script because the shell won't have noticed that you changed an
env variable...

The /^$/q just gets you out when the message starts so you don't snarf any body
messages


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] sam -d reading from stdin?
  2004-01-31 12:40 [9fans] sam -d reading from stdin? Matthias Teege
  2004-01-31 13:07 ` David Presotto
@ 2004-02-01  0:18 ` Geoff Collyer
  2004-02-01  0:30   ` Geoff Collyer
  2004-02-01  3:31 ` boyd, rounin
  2 siblings, 1 reply; 7+ messages in thread
From: Geoff Collyer @ 2004-02-01  0:18 UTC (permalink / raw)
  To: 9fans

This is how I use sam -d in a pipeline, taken from an existing shell script:

tcs -f msdos <$file |[3=1] sam -d /fd/3 <<'!' >[2]/dev/null
,x/
+$/ d
,x/
+/ x/
/ c/\n/
w /fd/1
!



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] sam -d reading from stdin?
  2004-02-01  0:18 ` Geoff Collyer
@ 2004-02-01  0:30   ` Geoff Collyer
  0 siblings, 0 replies; 7+ messages in thread
From: Geoff Collyer @ 2004-02-01  0:30 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 324 bytes --]

Whoops, that script won't make much sense, since the carriage returns
(ascii or utf 015) got turned into newlines (ascii or utf 012).  If
you replace each ~ with a carriage return, the script should look like
this:

tcs -f msdos <$file |[3=1] sam -d /fd/3 <<'!' >[2]/dev/null
,x/~+$/ d
,x/~+/ x/~/ c/\n/
w /fd/1
!

[-- Attachment #2: Type: message/rfc822, Size: 1889 bytes --]

From: Geoff Collyer <geoff@collyer.net>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] sam -d reading from stdin?
Date: Sat, 31 Jan 2004 16:18:21 -0800
Message-ID: <9c6fb52b5257fc8333b5722123939d01@collyer.net>

This is how I use sam -d in a pipeline, taken from an existing shell script:

tcs -f msdos <$file |[3=1] sam -d /fd/3 <<'!' >[2]/dev/null
,x/
+$/ d
,x/
+/ x/
/ c/\n/
w /fd/1
!

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] sam -d reading from stdin?
  2004-01-31 12:40 [9fans] sam -d reading from stdin? Matthias Teege
  2004-01-31 13:07 ` David Presotto
  2004-02-01  0:18 ` Geoff Collyer
@ 2004-02-01  3:31 ` boyd, rounin
  2004-02-01 13:51   ` Matthias Teege
  2 siblings, 1 reply; 7+ messages in thread
From: boyd, rounin @ 2004-02-01  3:31 UTC (permalink / raw)
  To: 9fans

http://www.insultant.net/code/dws.html



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] sam -d reading from stdin?
  2004-02-01  3:31 ` boyd, rounin
@ 2004-02-01 13:51   ` Matthias Teege
  2004-02-01 14:03     ` boyd, rounin
  0 siblings, 1 reply; 7+ messages in thread
From: Matthias Teege @ 2004-02-01 13:51 UTC (permalink / raw)
  To: 9fans

> http://www.insultant.net/code/dws.html

term% man rep
man: no manual page

Matthias


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] sam -d reading from stdin?
  2004-02-01 13:51   ` Matthias Teege
@ 2004-02-01 14:03     ` boyd, rounin
  0 siblings, 0 replies; 7+ messages in thread
From: boyd, rounin @ 2004-02-01 14:03 UTC (permalink / raw)
  To: 9fans

> term% man rep
> man: no manual page

true, but that's not the point.  you don't need rep.

i posted it as an example of how to use sam.

rep just repl[lies] to an rfc 822 message by
creating a reply template in a file.



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2004-02-01 14:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-31 12:40 [9fans] sam -d reading from stdin? Matthias Teege
2004-01-31 13:07 ` David Presotto
2004-02-01  0:18 ` Geoff Collyer
2004-02-01  0:30   ` Geoff Collyer
2004-02-01  3:31 ` boyd, rounin
2004-02-01 13:51   ` Matthias Teege
2004-02-01 14:03     ` boyd, rounin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).