[comp.unix.questions] Shell script for using interpreters

sreerang@castor.usc.edu (Sreeranga Rajan) (03/28/88)

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

I tried writing the following script, which failed to take in the
input from the keyboard. 
			lisp << 'EOF'
			(load <filename>)
			'EOF'
This loads the file and takes the input as EOF, which exits the Franz
lisp interpreter without waiting for my keyboard input.
Any help regarding this would be greatly appreciated.
---------------------------------------------------------------------
Sreeranga Rajan
Arpa: sreerang%castor.usc.edu@oberon.usc.edu
---------------------------------------------------------------------

arc1@eagle.ukc.ac.uk (A.R.Curtis) (03/29/88)

Expires:

Sender:

Followup-To:


In article <602@nunki.usc.edu> sreerang@castor.usc.edu (Sreeranga Rajan) writes:
>
>			enter lisp interpreter
>			load all the required files
>			take input from the keyboard after loading
>			the files

You'd better use your .lisprc mechanism to load the files.

Edit your .lisprc to contain (load 'foobar) type
instructions in sequence to load the files you want.  Of
course the .lisprc has to be in the current directory (or
home I think will also be tried)

Another method is to use liszt to compile your program (i.e. 
the list of files to load) with the ("-r" ?) bootstrap
option so you can just run it as a command in your script. 

When the program has loaded and booted it will then sit
waiting for input as usual



hope that helps


Tony



-- 
Tony Curtis, Computing Lab.                | arc1@uk.ac.ukc
Univ. Kent at Canterbury                   | 
Canterbury, Kent CT2 7NF                   | tcu@uk.ac.ex.cs

tom@tnosoes.UUCP (Tom Vijlbrief) (03/29/88)

In article <602@nunki.usc.edu> sreerang@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
>
>I tried writing the following script, which failed to take in the
>input from the keyboard. 
>			lisp << 'EOF'
>			(load <filename>)
>			'EOF'
>This loads the file and takes the input as EOF, which exits the Franz
>lisp interpreter without waiting for my keyboard input.

Try:

trap "/bin/rm -f /tmp/lispgo$$" 0 1 2 3 15
cat > /tmp/lispgo$$ << 'EOF'
(load <filename>)
EOF
cat -u /tmp/lispgo$$ - | lisp


===============================================================================
Tom Vijlbrief
TNO Institute for Perception
P.O. Box 23				Phone: +31 34 63 14 44
3769 DE  Soesterberg			E-mail: tnosoes!tom@mcvax.cwi.nl
The Netherlands				    or:	uunet!mcvax!tnosoes!tom
===============================================================================

lukas@ihlpf.ATT.COM (00704a-Lukas) (03/30/88)

In article <602@nunki.usc.edu> sreerang@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

I had (what I think is) a similar request to the net awhile back. It
involved a "startup" file (sf) of commands that I wanted executed each
time a given program was invoked. Logically, that involves catenating
the two sources together; I recieved several responses:

	(cat sf; cat) | prog
	cat sf - | prog
	cat sf /dev/tty | prog

There are slight differences; choose the one that best fits. You may
also need the -u option to cat.

I dont know if this is what you are looking for, or if it applies to
lisp; just trying to start paying back the debt I owe to the net.
-- 

	John Lukas
	ihnp4!ihlpf!lukas
	312-510-6290

richard@aiva.ed.ac.uk (Richard Tobin) (03/31/88)

In article <602@nunki.usc.edu> sreerang@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@uk.ac.ed             
AI Applications Institute,             ARPA:  R.Tobin%uk.ac.ed@nss.cs.ucl.ac.uk
Edinburgh University.                  UUCP:  ...!ukc!ed.ac.uk!R.Tobin

rex@otto.COM (Rex Jolliff) (04/07/88)

Expires:

Sender:

Followup-To:

Distribution:

Keywords:


>In article <602@nunki.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
>


well, if you're using FRANZ LISP (the version we are running here is
opus 38.79.), then you can create a file in your home directory called:

.lisprc

this will be loaded before the interpreter presents the first prompt.

                                                        Rex.
-- 

Rex Jolliff  (rex@otto.UUCP, {utah-gr, psivax, ihnp4, rutgers}!otto!rex)
The Sun Newspaper -            |Disclaimer:  The opinions and comments in
Nevada's Largest Daily Morning | this article are my own and in no way
Newspaper                      | reflect the opinions of my employers.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
What happened to our superior space program?