Shell script for using interpreters
Richard Tobin
richard at aiva.ed.ac.uk
Thu Mar 31 02:35:39 AEST 1988
In article <602 at nunki.usc.edu> sreerang at castor.usc.edu (Sreeranga Rajan) writes:
>I would like to know how I could write a shell script to perform the
>following actions:
> enter lisp interpreter
> load all the required files
> take input from the keyboard after loading
> the files
This is a common problem, not just for lisp. There are several solutions,
which work to different extents. Here are a few:
(1) cat -u file-of-commands - | lisp
This doesn't work very well, as the standard input to lisp is no longer
a terminal, but a pipe. In particular, typing EOF from a break level
will result in lisp exiting.
(2) lisp << 'EOF'
(load <filename>)
(setq piport (infile '/dev/tty))
'EOF'
I haven't worked out why this doesn't work properly. There are probably
several other solutions for people familiar with Franz lisp esoterica.
(3) Put something in your .lisprc that processes a command line argument
You can do this with (argv 1). Doesn't work for people without an
appropriate .lisprc.
(4) Write a C program
Always a winner. I assume you're using Berkeley unix if you've got
Franz lisp. You can insert (a certain number) of characters into a
terminal input stream using the TIOCSTI ioctl. A fragment of a program
to read characters from a file and insert them is:
int c;
while((c=getc(infile)) != EOF) ioctl(0, TIOCSTI, (struct sgttyb *)&c);
-- Richard
--
Richard Tobin, JANET: R.Tobin at uk.ac.ed
AI Applications Institute, ARPA: R.Tobin%uk.ac.ed at nss.cs.ucl.ac.uk
Edinburgh University. UUCP: ...!ukc!ed.ac.uk!R.Tobin
More information about the Comp.unix.questions
mailing list