9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Sam scripting
@ 2006-11-23  7:17 Koray Erkan
  2006-11-23 13:13 ` erik quanstrom
  0 siblings, 1 reply; 4+ messages in thread
From: Koray Erkan @ 2006-11-23  7:17 UTC (permalink / raw)
  To: Plan 9

Another Sam question (If enough voices raise objections, I'll try to create the "comp.editor.sam.do-play-it-again"
newsgroup) :

Can Sam be used as a *scripting* engine/server?

Its command language is powerful and just what I need for so many chores in some of my work (software localization), so
I'd be happy to learn that I can write a bunch of command sequences that I can mix with a scripting language (say a
Cygwin bash script, or a Pyhton/Ruby thing under Windows) and then forward them to Sam to batch process some files.


Thanks

-- Koray

P.S. Very pedantic note: The name rhymes with "rhye," not "say." Sorry, but it generally happens that with English
speakers, the spelling first becomes "Korey", then the "e" drops and it becomes "Kory", finally someone - thinking it's
best to avoid creative spelling - turns it into Cory. Nada! Not everything in Latin script is a transliteration of
something into English. In modern Turkish, our 'a' is always as in "car."




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

* Re: [9fans] Sam scripting
  2006-11-23  7:17 [9fans] Sam scripting Koray Erkan
@ 2006-11-23 13:13 ` erik quanstrom
  2006-11-23 13:36   ` Koray Erkan
  0 siblings, 1 reply; 4+ messages in thread
From: erik quanstrom @ 2006-11-23 13:13 UTC (permalink / raw)
  To: 9fans

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

sure, you can use sam for scripting.  one can suppress
starting samterm with the -d option.  though this is more
like using ed in a script than sed.

i attached a unix script that i use to find people in
address files with records containing a '^NAME	' field,
delimited by newlines.  it's written for byron's rc.

there's also an "ssam" out there analogous to sed.
i believe this is the url:
	http://www.freshports.org/editors/ssam/
though i haven't checked it myself.

- erik

[-- Attachment #2: tel.sam --]
[-- Type: text/plain, Size: 482 bytes --]

#!/usr/local/bin/rc
# bugs -- case sensitive matching

nl = '
'
bookdir = $home/doc/address
book = ()

if (~ $1 -b){
	shift
	if (~ $1 /* ./ ../)
		book = $1
	else
		book = $bookdir/$1
	shift
} else {
	for (i in $bookdir/*)
		if (test -f $i)
			book = ($book $i)
}

if (~ $#* 0)
	exit 0

args = $1
shift
for (i)
	args = $args'|'$i

echo 'X:.: , x/^\n/+/(.+\n)+/ g/^NAME.*('^$args^')/ p' | \
	sam -d $book >[2] /dev/null | \
	sed '2,$ s/^NAME/\'$nl'&/g'

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

* RE: [9fans] Sam scripting
  2006-11-23 13:13 ` erik quanstrom
@ 2006-11-23 13:36   ` Koray Erkan
  2006-11-25 20:17     ` LiteStar numnums
  0 siblings, 1 reply; 4+ messages in thread
From: Koray Erkan @ 2006-11-23 13:36 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Fantastic! Exactly what I needed. Thanks, Erik.

-- K

> -----Original Message-----
> From: 9fans-bounces+koray.erkan=yahoo.com@cse.psu.edu
> [mailto:9fans-bounces+koray.erkan=yahoo.com@cse.psu.edu]On Behalf Of erik quanstrom
> Sent: Thursday, November 23, 2006 3:13 PM
> To: 9fans@cse.psu.edu
> Subject: Re: [9fans] Sam scripting
>
>
> sure, you can use sam for scripting.  one can suppress
> starting samterm with the -d option.  though this is more
> like using ed in a script than sed.
>
> i attached a unix script that i use to find people in
> address files with records containing a '^NAME	' field,
> delimited by newlines.  it's written for byron's rc.
>
> there's also an "ssam" out there analogous to sed.
> i believe this is the url:
> 	http://www.freshports.org/editors/ssam/
> though i haven't checked it myself.
>
> - erik


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

* Re: [9fans] Sam scripting
  2006-11-23 13:36   ` Koray Erkan
@ 2006-11-25 20:17     ` LiteStar numnums
  0 siblings, 0 replies; 4+ messages in thread
From: LiteStar numnums @ 2006-11-25 20:17 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

This is the direct site:
http://www.westley.demon.co.uk/software.html
Or the direct link
http://www.westley.demon.co.uk/src/ssam-1.9.tar.gz

On 11/23/06, Koray Erkan <koray.erkan@yahoo.com> wrote:
> Fantastic! Exactly what I needed. Thanks, Erik.
>
> -- K
>
> > -----Original Message-----
> > From: 9fans-bounces+koray.erkan=yahoo.com@cse.psu.edu
> > [mailto:9fans-bounces+koray.erkan=yahoo.com@cse.psu.edu]On Behalf Of erik quanstrom
> > Sent: Thursday, November 23, 2006 3:13 PM
> > To: 9fans@cse.psu.edu
> > Subject: Re: [9fans] Sam scripting
> >
> >
> > sure, you can use sam for scripting.  one can suppress
> > starting samterm with the -d option.  though this is more
> > like using ed in a script than sed.
> >
> > i attached a unix script that i use to find people in
> > address files with records containing a '^NAME        ' field,
> > delimited by newlines.  it's written for byron's rc.
> >
> > there's also an "ssam" out there analogous to sed.
> > i believe this is the url:
> >       http://www.freshports.org/editors/ssam/
> > though i haven't checked it myself.
> >
> > - erik
>


-- 
If work and leisure are soon to be subordinated to this one utopian
principle -- absolute busyness -- then utopia and melancholy will come
to coincide: an age without conflict will dawn, perpetually busy --
and without consciousness.

 -- Günter Grass


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

end of thread, other threads:[~2006-11-25 20:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-23  7:17 [9fans] Sam scripting Koray Erkan
2006-11-23 13:13 ` erik quanstrom
2006-11-23 13:36   ` Koray Erkan
2006-11-25 20:17     ` LiteStar numnums

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).