[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MIT-Scheme-devel] Reading command-line arguments from MIT-Scheme.
From: |
giorgio xyzb |
Subject: |
Re: [MIT-Scheme-devel] Reading command-line arguments from MIT-Scheme. |
Date: |
Wed, 15 Aug 2012 20:47:26 +0000 |
Hello again,
I managed to find a solution, which seems to work.
I have created a file init.scm with the following content:
(define command-line-args '())
(define parse-argument-list
(lambda (arg-list)
(set! command-line-args
(if (null? arg-list)
(list)
(cdr arg-list)))))
(set-command-line-parser! "args" parse-argument-list)
In this way, when the command line option --args is found, the function
parse-argument-list is invoked.
I have loaded this file into the mit-scheme interpreter and saved a world image
(init.com) using the procedure disk.save.
I have then written a shell script (bash) that invokes my main Scheme script as
follows:
mit-scheme --band "init.com" --interactive --batch-mode --args $* <
myscript.scm
Finally, in my main script I can access the command line arguments through the
variable
command-line-args
I hope this is the standard / correct way to do this.
Best regards
Giorgio
>
> Hello,
>
> a few days ago I have installed MIT Scheme (MIT/GNU Scheme running under
> Ubuntu
> Linux 10.04)
> and I have started experimenting with it.
>
> One thing I would like to do is start a Scheme application from the
> command-line and pass it some
> parameters, like so:
>
> $ mit-scheme myapplication.scm par1 par2 par3
>
> I have searched the documentation at http://www.gnu.org/software/mit-scheme/
> but I could not find
> any information on this topic.
>
> I wanted to ask if it is possible to access command-line parameters from
> MIT-Scheme and how.
>
> Thank you in advance and best regards
> Giorgio
>
- Re: [MIT-Scheme-devel] Reading command-line arguments from MIT-Scheme.,
giorgio xyzb <=