From: Mark Tarver
Subject: Lisp as a scripting language
Date: 
Message-ID: <1147688973.221574.138590@i40g2000cwc.googlegroups.com>
I'm hearing things about using
Lisp as a scripting language.
Does anybody know any good
introductions? My server runs
Windows.

Note I do not have superuser
access to my server - I just rent
space.

Mark

From: ········@gmail.com
Subject: Re: Lisp as an Operating System (was: ... as a Scripting Language)
Date: 
Message-ID: <1147705623.799424.323650@j33g2000cwa.googlegroups.com>
Why stop at a scripting language: Why not have Lisp as your whole OS:

       http://nostoc.stanford.edu/Docs/KnowOS.html
From: Mark Tarver
Subject: Re: Lisp as an Operating System (was: ... as a Scripting Language)
Date: 
Message-ID: <1147707134.799430.293900@i40g2000cwc.googlegroups.com>
Sounds great.  But at the moment I'm
at the 'Hello world' stage.  I don't think
my provider would buy into it.

Mark
From: Bill Atkins
Subject: Re: Lisp as an Operating System
Date: 
Message-ID: <87hd3rl0gd.fsf@rpi.edu>
"Mark Tarver" <··········@ukonline.co.uk> writes:

> Sounds great.  But at the moment I'm
> at the 'Hello world' stage.  I don't think
> my provider would buy into it.
>
> Mark
>

You might be better off with a different provider.  If you want to run
Lisp on a server, you probably need to run your own Lisp image - and
you probably don't want a Windows server.  There are several hosting
companies that will give you root access to a User-mode Linux machine
for $30 a month.  Your provider never has to buy into anything.

-- 
You fool! You fell victim to one of the classic blunders! The most
famous is, "Never get involved in a land war in Asia", but only
slightly less well-known is this: "Never go in against a Sicilian when
death is on the line"!
From: Mark Tarver
Subject: Lisp as a scripting language
Date: 
Message-ID: <1147719926.003021.326040@j55g2000cwa.googlegroups.com>
You might be right- they
could move me to Unix
possibly if I asked - but
it would be great to find
anybody who has written
an interactive script for
a Windows site using 
CLisp.  Anybody out there?

Mark
From: Bill Atkins
Subject: Re: Lisp as a scripting language
Date: 
Message-ID: <871wuv83km.fsf@rpi.edu>
"Mark Tarver" <··········@ukonline.co.uk> writes:

> You might be right- they
> could move me to Unix
> possibly if I asked - but
> it would be great to find
> anybody who has written
> an interactive script for
> a Windows site using 
> CLisp.  Anybody out there?
>
> Mark
>

What do you mean by "an interactive script"?

-- 
You fool! You fell victim to one of the classic blunders! The most
famous is, "Never get involved in a land war in Asia", but only
slightly less well-known is this: "Never go in against a Sicilian when
death is on the line"!
From: Mark Tarver
Subject: Re: Lisp as a scripting language
Date: 
Message-ID: <1147726633.156484.63890@j33g2000cwa.googlegroups.com>
I mean a script that allows
me to build interactive web
pages.

Mark
From: Rob Warnock
Subject: Re: Lisp as a scripting language
Date: 
Message-ID: <3-mdnb4Mp4DxpPTZRVn-sw@speakeasy.net>
Mark Tarver <··········@ukonline.co.uk> wrote:
+---------------
| I mean a script that allows me to build interactive web pages.
+---------------

See <http://rpw3.org/hacks/lisp/clisp-demo.cgi> for a
page which I suspect you might consider "interactive".

Caveat: The server "rpw3.org" is running FreeBSD, not
Windows, and as you'll see from the source (included)
I had to write a small CGI library of my own (but perhaps
<http://www.cliki.net/lisp-cgi-utils> will do if you
don't want to write your own).


-Rob

p.s. <http://rpw3.org/hacks/lisp/appsrv-demo.lhp> runs
a *LOT* faster than the above CGI script, since it uses
(1) compiled CMUCL code, and (2) a persistent Lisp server
that caches previously-referenced pages. But that's a
whole 'nother story...

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: ········@gmail.com
Subject: Re: Lisp as an Operating System (was: ... as a Scripting Language)
Date: 
Message-ID: <1147793705.840249.192520@i39g2000cwa.googlegroups.com>
> Sounds great.  But at the moment I'm
> at the 'Hello world' stage.  I don't think
> my provider would buy into it.

Sure, but maybe you should be paying me instead of your hosting
service. I'd run a KnowOS instead of (or, more precisely: on top of)
the Linux box(es) for you.

I'm not actually offering to become your web host, but this is part of
the KnowOS Vision: Instead of talking to Linux, you talk to a KnowOS --
i.e., a Lisp engine loaded with the knowledge that you want to use --
analogous to the way that Linux is loaded with the files that you want
to use. The KnowOS is supported by the server managers -- analogous to
the way they support Linux for you now. And it enables you to talk to
Linux services, or other web services as needed when needed if needed.
From: Paolo Amoroso
Subject: Re: Lisp as a scripting language
Date: 
Message-ID: <874pzrwjqh.fsf@plato.moon.paoloamoroso.it>
"Mark Tarver" <··········@ukonline.co.uk> writes:

> I'm hearing things about using
> Lisp as a scripting language.
> Does anybody know any good
> introductions? My server runs

Here are some starting points:

  ShellScripting
  http://www.cliki.net/ShellScripting

  CLISP-Shell
  http://www.cliki.net/CLISP-Shell

  Lisp as a shell
  http://www.cliki.net/Lisp%20as%20a%20shell

  cl-launch
  http://www.cliki.net/cl-launch

I don't know whether this material also applies to your environment.


Paolo
-- 
Why Lisp? http://wiki.alu.org/RtL%20Highlight%20Film
The Common Lisp Directory: http://www.cl-user.net
From: Pascal Bourguignon
Subject: Re: Lisp as a scripting language
Date: 
Message-ID: <87u07q3o1n.fsf@thalassa.informatimago.com>
"Mark Tarver" <··········@ukonline.co.uk> writes:
> I'm hearing things about using
> Lisp as a scripting language.
> Does anybody know any good
> introductions? My server runs
> Windows.
>
> Note I do not have superuser
> access to my server - I just rent
> space.


Note that the unsatisfactorily answers are given mostly because of
your MS-Windows constaints.  I don't know how to write a MS-Windows
script.  I guess that would be a .BAT file.  How does Apache run .BAT
files as CGI?  I mean, MS-Windows won't run a script following the #!
convention will it?

There is nothing more simple than the CGI interface: the web server
just runs the script, passing information in the  environment
variables, and in the case of a POST method, sending the data from the
web client to the standard input of the script.  It collects the data
from the standard output of the script and forwards it to the web
client (this should be a few lines of header information, including a
Content-Type: header, followed by an empty line and the data
(generally, it's text/html).  

There absolutely no difficulty to write such a program in lisp.
(Well, in a given implementation of lisp, since the notion of
environment variable is not covered by the Common Lisp standard, you
have to rely on implementation specific functions.  In clisp, it's
EXT:GETENV).

The problem is how to hook things up in MS-Windows.  I don't know
anything about MS-Windows.  Do you know it?


So, assuming that you can configure Apache to run a .BAT script, I bet
you could run a clisp program from a .BAT script containing:

----C:\CGI\EXAMPLE.BAT-----------------------------------

C:\BIN\CLISP.EXE -q -ansi -norc -i C:\CGI\EXAMPLE.LSP

----C:\CGI\EXAMPLE.LSP-----------------------------------

(defparameter *myself* "EXAMPLE.BAT")

(defmacro h (tag-attrs &rest body)
  (let ((tag (if (consp tag-attrs) (car tag-attrs) tag-attrs)))
    `(unwind-protect
          (progn
            (format t "~&<···@{ ~A=\"~A\"~}>" 
                    ',tag
                    ,@(when (consp tag-attrs) (cdr tag-attrs)))
            ,@body)
       (format t "</~A>" ',tag))))

(defun formular (method)
  (h (form :action *myself* :method method)
     (h br)(h (select :name "op")
              (h (option :value "add" :label "Add" :selected :selected)
                 (princ "Sum"))
              (h (option :value "sub" :label "Subtract")
                 (princ "Difference"))
              (h (option :value "mul" :label "Multiply")
                 (princ "Product"))
              (h (option :value "div" :label "Divide")
                 (princ "Division")))
     (h br)(h (input :type "text" :name "arg1" :size 60 :maxlength 60))
     (h br)(h (input :type "text" :name "arg2" :size 60 :maxlength 60))
     (h br)(h (button :type "submit")
              (princ "Execute"))))

(defun formular-page ()
  (h html
     (h head
        (h title (princ "form test cgi")))
     (h (body :bgcolor "#4499ff")
        (h h1 (princ "Input parameters"))
        (h h2 (princ "Get"))
        (formular "get")
        (h h2 (princ "Post"))
        (formular "post")
        (h h1 (princ "Environment"))
        (dump-environment))))


(defun split-string (string separator)
  (loop 
     :for start = 0 :then (1+ sepos)
     :for sepos = (position separator string :start start)
     :collect (subseq string start (and (< start (length string)) sepos))
     :while sepos))

(defun decode-query (query-string)
  (mapcar (lambda (arg) (split-string arg #\=))
           (split-string query-string #\&)))


(defparameter *functions* 
  (let ((table (make-hash-table :test (function equal))))
    (setf (gethash "add" table) (cons (function +) (quote +))
          (gethash "sub" table) (cons (function -) (quote -))
          (gethash "mul" table) (cons (function *) (quote *))
          (gethash "div" table) (cons (function /) (quote /)))
    table))

(defun argument (name query)
  (or (second (assoc name query :test (function equal))) ""))

(defun process (query)
  (h h1 (princ "Results"))
  (let ((op   (gethash (argument "op" query) *functions*))
        (arg1 (let ((*read-eval* nil))
                (read-from-string (argument "arg1" query))))
        (arg2 (let ((*read-eval* nil))
                (read-from-string (argument "arg2" query)))))
    (h p 
       (if (and op (numberp arg1) (numberp arg2))
           (format t "~A ~A ~A = ~A" 
                   arg1 (cdr op) arg2 
                   (funcall (car op) arg1 arg2))
           (format t "Invalid or missing operator or arguments.")))))

(defun dump-environment ()
  (h table
     (dolist (env (ext:getenv))
       (h tr (h td (princ (car env)))  (h td (princ (cdr env)))))))

(defun process-page (query)
  (h html
     (h head
        (h title (princ "results")))
     (h (body :bgcolor "#4499ff")
        (process query)
        (h h1 (princ "New operation"))
        (h h2 (princ "Get"))
        (formular "get")
        (h h2 (princ "Post"))
        (formular "post")
        (h h1 (princ "Environment"))
        (dump-environment))))

(defun process-post ()
  (h html
     (h head
        (h title (princ "post request results")))
     (h (body :bgcolor "#4499ff")
        (h h1 (princ "New operation"))
        (h h2 (princ "Get"))
        (formular "get")
        (h h2 (princ "Post"))
        (formular "post")
        (h h1 (princ "Environment"))
        (dump-environment)
        (h h1 (princ "Stdin"))
        (h pre
           (loop :for line = (read-line *standard-input* nil nil)
              :while line
              :do (format t "~A~%" line))))))

(format t "Content-type: text/html~2%")
(handler-case
    (if (string-equal "POST"  (ext:getenv "REQUEST_METHOD"))
        (process-post)
        (let ((query (ext:getenv "QUERY_STRING")))
          (if (and query (< 0 (length query)))
              (process-page (decode-query query))
              (formular-page))))
  (error (err)
    (h (body :bgcolor "#ff9944")
       (h h1 (princ "Some Error occured"))
       (h pre (princ err))
       (h h1 (princ "Environment"))
       (dump-environment))))

(ext:exit 0) 




-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
        Un chat errant
se soulage
        dans le jardin d'hiver
                                        Shiki
From: Mark Tarver
Subject: Re: Lisp as a scripting language
Date: 
Message-ID: <1147774339.834786.186350@i39g2000cwa.googlegroups.com>
> I mean, MS-Windows won't run a script following the #! convention will it?

Probably not.

> I don't know how to write a MS-Windows script.  I guess that would be a .BAT file.

That's a good a guess as any that I know.   What I need to do is to try
out some ideas
on my machine before trying it on their server.

My original idea was to invoke Lisp through another language like Perl
which does run
on this server.

Mark
From: Mark Tarver
Subject: Re: Lisp as a scripting language
Date: 
Message-ID: <1147807771.246447.53740@y43g2000cwc.googlegroups.com>
Would this work?  I'm sure I've
got Perl on this server.

One method is to dump the
user input into a file and then
call Lisp to execute the file.  To
do this I need to be able to
call the executable .bat file.

Ergo Perl needs to be able to
do three things.

1.  To grab the environment variables
     and their values and dump them into
     a file F.

2.  To call the Lisp image on the server
     which reads in F and does the job of
     producing the HTML file H.

3.  To direct the browser to the file H.

Now is this a goer in Perl or not? 

Mark
From: Pascal Bourguignon
Subject: Re: Lisp as a scripting language
Date: 
Message-ID: <87iro5zefa.fsf@thalassa.informatimago.com>
"Mark Tarver" <··········@ukonline.co.uk> writes:

> Would this work?  I'm sure I've
> got Perl on this server.

I don't know. You seem to know less of MS-Windows than me.  Are you
sure you're wanting to run MS-Windows?

> One method is to dump the
> user input into a file and then
> call Lisp to execute the file.  

What are you trying to do?  This is one method to do what?

> To do this I need to be able to
> call the executable .bat file.
>
> Ergo Perl needs to be able to
> do three things.
>
> 1.  To grab the environment variables
>      and their values and dump them into
>      a file F.
>
> 2.  To call the Lisp image on the server
>      which reads in F and does the job of
>      producing the HTML file H.
>
> 3.  To direct the browser to the file H.
>
> Now is this a goer in Perl or not? 

I don't know.  Perhaps it would be good to add a python script in the middle:

[Apache] --> [.BAT] --> [Perl] --> [Python] --> [let's add Ryby too] --> [clisp]


I explained you that clisp is perfectly capable of doing exactly what
you're describing above for perl?  Why don't you want to do it in clisp?

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

"A TRUE Klingon warrior does not comment his code!"
From: Mark Tarver
Subject: Re: Lisp as a scripting language
Date: 
Message-ID: <1147853586.752149.30050@j73g2000cwa.googlegroups.com>
> Note that the unsatisfactorily answers are given mostly because of
> your MS-Windows constaints.

This is not me being stubborn.
I don't want to actually move all my stuff
off my provider which I've been happy with
and which has provided me with cheap good service
just cos of Windows.  Apart from that, I'd like
a generic solution that works across different
platforms.

> You seem to know less of MS-Windows than me.

Quite possible.  I just use it; I don't program it.

> There is nothing more simple than the CGI interface: the web server
> just runs the script, passing information in the  environment
> variables, and in the case of a POST method, sending the data from the
> web client to the standard input of the script.

Intellectually trivial to understand what is needed, to be sure.
But notice nobody has dived in here yet and said "Hey, no
problems, I've done it under Windows. Here it is"  This kind of stuff
is always easy when you've found the magic lines.

Mark.
From: Burton Samograd
Subject: Re: Lisp as a scripting language
Date: 
Message-ID: <87sln9uizl.fsf@gmail.com>
"Mark Tarver" <··········@ukonline.co.uk> writes:

> Intellectually trivial to understand what is needed, to be sure.
> But notice nobody has dived in here yet and said "Hey, no
> problems, I've done it under Windows. Here it is"  This kind of stuff
> is always easy when you've found the magic lines.

I'm pretty sure not many of us use windows here, hence no real answer
other than "switch to what we're using and we'll gladly help".

-- 
burton samograd					kruhft .at. gmail
kruhft.blogspot.com	www.myspace.com/kruhft	metashell.blogspot.com
From: Pascal Bourguignon
Subject: Re: Lisp as a scripting language
Date: 
Message-ID: <87odxxx8qe.fsf@thalassa.informatimago.com>
Burton Samograd <······@gmail.com> writes:

> "Mark Tarver" <··········@ukonline.co.uk> writes:
>
>> Intellectually trivial to understand what is needed, to be sure.
>> But notice nobody has dived in here yet and said "Hey, no
>> problems, I've done it under Windows. Here it is"  This kind of stuff
>> is always easy when you've found the magic lines.
>
> I'm pretty sure not many of us use windows here, hence no real answer
> other than "switch to what we're using and we'll gladly help".

My personnal 10-feet pole I use to touch MS-Windows is cygwin.  In
cygwin, there's an apache server and perl and clisp, etc, and they
just work like on unix (#!/usr/bin/clisp, etc).

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
Small brave carnivores
Kill pine cones and mosquitoes
Fear vacuum cleaner
From: Yves Vandriessche
Subject: Re: Lisp as a scripting language
Date: 
Message-ID: <e4ev3l$kgg$1@ikaria.belnet.be>
Pascal Bourguignon wrote:
> Burton Samograd <······@gmail.com> writes:
> 
> 
>>"Mark Tarver" <··········@ukonline.co.uk> writes:
>>
>>
>>>Intellectually trivial to understand what is needed, to be sure.
>>>But notice nobody has dived in here yet and said "Hey, no
>>>problems, I've done it under Windows. Here it is"  This kind of stuff
>>>is always easy when you've found the magic lines.
>>
>>I'm pretty sure not many of us use windows here, hence no real answer
>>other than "switch to what we're using and we'll gladly help".
> 
> 
> My personnal 10-feet pole I use to touch MS-Windows is cygwin.  In
> cygwin, there's an apache server and perl and clisp, etc, and they
> just work like on unix (#!/usr/bin/clisp, etc).
> 

VMware player + ubuntu preset image (all for free) is also a good 
option, works great.
From: Bill Atkins
Subject: Re: Lisp as a scripting language
Date: 
Message-ID: <87d5echmik.fsf@rpi.edu>
"Mark Tarver" <··········@ukonline.co.uk> writes:

[snip]
> Intellectually trivial to understand what is needed, to be sure.
> But notice nobody has dived in here yet and said "Hey, no
> problems, I've done it under Windows. Here it is"  This kind of stuff
> is always easy when you've found the magic lines.

I think part of the problem is that you've been a little vague about
what you want and about the kind of access you have to the server.  If
you are really just trying to run a web application in Lisp, it's
probably more reasonable to start your Lisp image up once, set up a
Lisp server within it, and then get your regular web server to act as
a proxy to your Lisp image for certain requests.  Lisp is intended
more to be started once and left running than to go through the
start-stop of CGI; your Lisp image may or may not start fast enough
for use as a CGI script.

If you can't set up a proxy (there's no way for anyone here to know
what kind of control you have over this server), perhaps your Perl
script makes sense as a kind of lightweight proxy that your hosts
won't have a problem with.

If you really do want to use CGI, I would imagine there's no
difference between configuring Windows Apache to invoke Perl for .pl
files and having it invoke CLISP for .lisp files.

-- 
You fool! You fell victim to one of the classic blunders! The most
famous is, "Never get involved in a land war in Asia", but only
slightly less well-known is this: "Never go in against a Sicilian when
death is on the line"!
From: Pascal Bourguignon
Subject: Re: Lisp as a scripting language
Date: 
Message-ID: <87sln9x8xt.fsf@thalassa.informatimago.com>
"Mark Tarver" <··········@ukonline.co.uk> writes:

>> Note that the unsatisfactorily answers are given mostly because of
>> your MS-Windows constaints.
>
> This is not me being stubborn.
> I don't want to actually move all my stuff
> off my provider which I've been happy with
> and which has provided me with cheap good service
> just cos of Windows.  Apart from that, I'd like
> a generic solution that works across different
> platforms.
>
>> You seem to know less of MS-Windows than me.
>
> Quite possible.  I just use it; I don't program it.
>
>> There is nothing more simple than the CGI interface: the web server
>> just runs the script, passing information in the  environment
>> variables, and in the case of a POST method, sending the data from the
>> web client to the standard input of the script.
>
> Intellectually trivial to understand what is needed, to be sure.
> But notice nobody has dived in here yet and said "Hey, no
> problems, I've done it under Windows. Here it is"  This kind of stuff
> is always easy when you've found the magic lines.

It should probably be quite similar to what you have to do to get a
perl script run as a CGI.  Just substitute clips for perl in the right
place, and it should work.

I mean, on unix, we'd just write #!/usr/bin/clisp instead of
#!/usr/bin/perl at the start of the CGI script.  Similarly, on
MS-Windows you'd just write clisp in the right place.


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
Small brave carnivores
Kill pine cones and mosquitoes
Fear vacuum cleaner
From: Mark Tarver
Subject: Re: Lisp as a scripting language
Date: 
Message-ID: <1147860646.672287.251370@j73g2000cwa.googlegroups.com>
> I mean, on unix, we'd just write #!/usr/bin/clisp instead of
> #!/usr/bin/perl at the start of the CGI script.  Similarly, on
> MS-Windows you'd just write clisp in the right place.

Thats exactly it - thats the magic line I need to find.

Mark
From: ········@gmail.com
Subject: Re: Lisp as a scripting language
Date: 
Message-ID: <1147896236.782927.38190@u72g2000cwu.googlegroups.com>
Mark Tarver wrote:
> I'm hearing things about using
> Lisp as a scripting language.
> Does anybody know any good
> introductions? My server runs
> Windows.
>
> Note I do not have superuser
> access to my server - I just rent
> space.
>
> Mark

Try Lsharp. Pure managed code and scripting access to the .net
libraries. Works great as a scripting language.