Path: utzoo!mnetor!uunet!mcvax!ukc!its63b!aiva!richard From: richard@aiva.ed.ac.uk (Richard Tobin) Newsgroups: comp.unix.questions Subject: Re: Shell script for using interpreters Message-ID: <310@aiva.ed.ac.uk> Date: 30 Mar 88 16:35:39 GMT References: <134@longway.TIC.COM> <602@nunki.usc.edu> Reply-To: richard@uk.ac.ed.aiva (Richard Tobin) Organization: Bannerman's Bar, Cowgate, Edinburgh Lines: 45 Keywords: Lisp, shell script. 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 ) (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