Hello
Teach me please how to write simple echo program on CL
like the following written in C:
#include <stdio.h>
int main(argc, argv)
int argc;
char **argv;
{
int i;
for (i = 0; i < argc; ++i)
printf("arg[%d] = '%s'\n", i, argv[i]);
}
$ ./echo2 hi there
arg[0] = './echo2'
arg[1] = 'hi'
arg[2] = 'there'
$
Can I call those program on CL in the simple manner ?
E.g. suppose ECHO.x86f contains compiled ECHO.lisp
file. Is it possible to call it like the following:
$ echo hi there
Using CMUCL on Slackware 7.0
Thanks in advance
--
Vladimir Zolotych ······@eurocom.od.ua
"Vladimir V. Zolotych" <······@eurocom.od.ua> writes:
[starting a lisp program from the command line]
>
> Can I call those program on CL in the simple manner ?
> E.g. suppose ECHO.x86f contains compiled ECHO.lisp
> file. Is it possible to call it like the following:
>
> $ echo hi there
>
> Using CMUCL on Slackware 7.0
>
Two parts of your question: starting compiled lisp programs easily and
getting the command line switches. For the second,
(apropos "command-line" (find-package "EXT"))
should get you started, at least on CMUCL. The manual also has this
information, if I recall correctly.
For the first question, Linux has a way of associating various file
types with executables to start them (e.g. Java .class files). I
don't recall the specifics right now, but the kernel must be compiled
with binfmt_misc enabled and you have to echo some information into
/proc/binfmt_misc (file names etc. are likely to be inaccurate,
sorry). Or look at CLOCC (<http://clocc.sourceforge.net/>); in the
bin/ directory of the distribution, there is a shell script run-lisp
that knows how to start up various lisps, make them load files,
execute forms, etc.
Hope this helps some,
Rudi
Here is the summary (Thanks to Paul Foley and
Rudolf Schlatte)
Using Slackware 7.0
The CL echo program (file ECHO.lisp)
(loop for arg in *command-line-strings* as i upfrom 0 do
(format t "~&arg[~D] = ~S" i arg))
(terpri)
Shell script (file /usr/local/lib/batch)
#!/bin/sh
exec /usr/local/bin/lisp -batch -load $*
Settings for binfmt_misc
# cd /proc/sys/fs/binfmt_misc/
# echo ':CMUCL:M::FASL FILE::/usr/local/lib/batch:' >register
Running ECHO.x86f
$ echo.x86f 1 2 3
; Loading #p"/home/vlz/.cmucl-init.lisp".
; Loading #p"/home/vlz/cmucl/echo/echo.x86f".
arg[0] = "/usr/local/bin/lisp"
arg[1] = "-batch"
arg[2] = "-load"
arg[3] = "./echo.x86f"
arg[4] = "1"
arg[5] = "2"
arg[6] = "3"
$
--
Vladimir Zolotych ······@eurocom.od.ua
······@schlund.de (Hannah Schroeter) writes:
> Linux specific...
You deleted the line at the top of the post you followed up to which
said
> Using Slackware 7.0
In that context, I don't think there's very much wrong with being
Linux-specific.
-dan
--
http://ww.telent.net/cliki/ - Link farm for free CL-on-Unix resources