From: Rod Gammon
Subject: Calling LISP functions from Shell (linux) - how?
Date: 
Message-ID: <3487A12F.48FC@hawaii.edu>
I am wondering if I can compile a lisp file so that I could call it from
a shell command line-- that is make small filters & such using lisp.  I
would like to be able to pipe in etc.

I have experience using acl, but only in emacs and top loop.  I'd like
to bring some of that to my command line.

Any help appreciated,
rg

From: Ketil Z Malde
Subject: Re: Calling LISP functions from Shell (linux) - how?
Date: 
Message-ID: <KETIL-ylfa4t4o9ne2.fsf@jenufa.infotek.no>
Rod Gammon <······@hawaii.edu> writes:

> I am wondering if I can compile a lisp file so that I could call it from
> a shell command line-- that is make small filters & such using lisp.  I
> would like to be able to pipe in etc.

Since you mention Linux - there's a facility in the kernel, called
something like "misc binary support" or some such, which used to be
support for running .class files through a Java VM, but is now extended
to be configurable for any kind of  executable file.

You could probably configure it to have lisp files executed with some
interpreter.  I suggest you look for further information in the
Documentation directory of the Linux kernel.

~kzm
-- 
If I haven't seen further, it is by standing in the footprints of giants
From: Espen Vestre
Subject: Re: Calling LISP functions from Shell (linux) - how?
Date: 
Message-ID: <w6lny0krxf.fsf@gromit.nextel.no>
Ketil Z Malde <·····@ii.uib.no> writes:

> You could probably configure it to have lisp files executed with some
> interpreter.  I suggest you look for further information in the
> Documentation directory of the Linux kernel.

hey, this is interesting!

rather than letting it just push the files into some interpreter,
what if your "interpreter" was some very, very mininal program
talking (through sockets?) to a background-running lisp process 
(one per user) to check whether there's a need to compile the 
files (or whether they already *are* fasl-files) and then load them, 
piping i/o throug standard i/o of the minimal "interpreter"?

(of course, we harcore lispists think this is a backward way of
doing things, but while we wait for the ultimate lisp environment
which will free us from csh & friends forever, this could really
be interesting! and it could enable us to make the lisp-ignorants
use our lisp-code without even noticing ;-))

--

(espen vestre
  (telenor nextel as norway))
From: Zellyn Hunter
Subject: Re: Calling LISP functions from Shell (linux) - how?
Date: 
Message-ID: <66i0g9$nb1@solaria.cc.gatech.edu>
Espen Vestre (··@nextel.no) wrote:
: rather than letting it just push the files into some interpreter,
: what if your "interpreter" was some very, very mininal program
: talking (through sockets?) to a background-running lisp process 
: (one per user) to check whether there's a need to compile the 
: files (or whether they already *are* fasl-files) and then load them, 
: piping i/o throug standard i/o of the minimal "interpreter"?

Wow.  Nice idea!  We did almost exactly that for our senior design
class - only we're shipping code across sockets on different
computers to allow a MOO to be programmed in Lisp... or C... or
whatever (we just did Lisp and C as examples of very different
langauges)

I think loading compiled files might be difficult - since you want
to load each into its own package for safety - can you do that with
compiled files?

Just wondering...

Zellyn

--
Zellyn Hunter                       Loneliness is a
······@cc.gatech.edu               terrible price to
404-206-1729                      pay for independence
From: Karl M. Hegbloom
Subject: Re: Calling LISP functions from Shell (linux) - how?
Date: 
Message-ID: <87k9dj5d2u.fsf@bittersweet.inetarena.com>
>>>>> "Rod" == Rod Gammon <······@hawaii.edu> writes:

    Rod> I am wondering if I can compile a lisp file so that I could
    Rod> call it from a shell command line-- that is make small
    Rod> filters & such using lisp.  I would like to be able to pipe
    Rod> in etc.

 I've found that the Elk (Extension Language Kit) scheme interpreter
 works pretty well like that.  You can pipe a script into it.
From: Kent M Pitman
Subject: Re: Calling LISP functions from Shell (linux) - how?
Date: 
Message-ID: <sfw90tzpbmu.fsf@world.std.com>
Rod Gammon <······@hawaii.edu> writes:

> I am wondering if I can compile a lisp file so that I could call it from
> a shell command line-- that is make small filters & such using lisp.  I
> would like to be able to pipe in etc.
> 
> I have experience using acl, but only in emacs and top loop.  I'd like
> to bring some of that to my command line.

You might consider using GNU Emacs itself and specifying different
files as init files.  I know it is possible to invoke Emacs so that it
only runs a lisp script and then exits, never enters interactive
editing mode, though I don't know how.  Emacs and Emacs Lisp is pretty
well-documented, both in its self-documentation and in commercially
available books you can find at any good technical bookstore.
From: Bruce Tobin
Subject: Re: Calling LISP functions from Shell (linux) - how?
Date: 
Message-ID: <348B09D6.127D@infinet.com>
Rod Gammon wrote:
> 
> I am wondering if I can compile a lisp file so that I could call it from
> a shell command line-- that is make small filters & such using lisp.  

 Take a look at scsh-- the Scheme Shell:

  http://www.landfield.com/faqs/unix-faq/shell/scsh-faq/
From: Bruno Haible
Subject: Re: Calling LISP functions from Shell (linux) - how?
Date: 
Message-ID: <1641p17955@clisp.cons.org>
Rod Gammon <······@hawaii.edu> wrote:
> I am wondering if I can compile a lisp file so that I could call it from
> a shell command line-- that is make small filters & such using lisp.  I
> would like to be able to pipe in etc.

On Unix, the #! hook makes this possible. Here is, for example, an emulation
of "cat" in Common Lisp:

#!/usr/local/bin/clisp
(defun cat-file (stream)
  (loop
    (let ((line (read-line stream nil nil)))
      (if line (write-line line *standard-output*) (return))
) ) )
(dolist (arg *args*)
  (if (string= arg "-")
    (cat-file *standard-input*)
    (with-open-file (f arg :direction :input) (cat-file f))
) )

CLISP for Linux is on {ftp,http}://sunsite.unc.edu/pub/Linux/devel/lang/lisp/.
The caveats of this method are listed in section 99.8 of the impnotes file.

                            Bruno