From: someusernamehere
Subject: how to get the program name?
Date: 
Message-ID: <e438ab45-b4b4-41c8-8160-b880e611a24a@d27g2000prf.googlegroups.com>
hey, I have a program called foobar.lisp, which contain stuff like:
#!/usr/bin/clisp
(format t
(......)
 (.....)
  (

                ))


How I can with some function or whatever within my foobar.lisp obtain
your name (I mean obtain foobar.lisp or if the file is renamed obtain
the new name)

thanks

From: D Herring
Subject: Re: how to get the program name?
Date: 
Message-ID: <lcadnUWVv9iQPczanZ2dnUVZ_gKdnZ2d@comcast.com>
someusernamehere wrote:
> hey, I have a program called foobar.lisp, which contain stuff like:
> #!/usr/bin/clisp
> (format t
> (......)
>  (.....)
>   (
> 
>                 ))
> 
> 
> How I can with some function or whatever within my foobar.lisp obtain
> your name (I mean obtain foobar.lisp or if the file is renamed obtain
> the new name)

I don't think there's any direct support for this in the ANSI 
standard; how to handle definitions from file, repl, network IO, etc?

Here's a couple (untested) trampoline scripts you might try.

cat <<"_EOF" > clisp-trampoline.sh
#!/bin/bash

LISP=/usr/bin/clisp
SCRIPT=/path/to/file.lisp
$LISP -q $SCRIPT $0 $SCRIPT ·@

# In lisp, read the arguments from EXT:*ARGS*
_EOF


cat <<"_EOF" > sbcl-trampoline.sh
#!/bin/bash

LISP=/usr/local/bin/sbcl
SCRIPT=/path/to/file.lisp
$LISP --noinform --load $SCRIPT --end-toplevel-options $0 $SCRIPT ·@

# In lisp, read the arguments from SB-EXT:*POSIX-ARGV*
_EOF


- Daniel
From: Frank Goenninger DG1SBG
Subject: Re: how to get the program name?
Date: 
Message-ID: <lz7ijy2ob5.fsf@pcsde001.de.goenninger.net>
someusernamehere <················@gmail.com> writes:

(defun argv0 ()
  #+allegro (sys:command-line-argument 0)
  #+lispworks (nth 0 system:*line-arguments-list*) ;; portable to OS X
  #+sbcl (nth 0 sb-ext:*posix-argv*)
  #+openmcl (car ccl:*command-line-argument-list*)
  #-(or allegro lispworks sbcl openmcl)
  (error "argv0 function not implemented for this lisp"))


and then

(format t "My name is ~s.~%" (argv0))

will print the name of the executable running.

To get the filename of the _source_ file you could do:

#.(or *compile-file-truename* *load-truename*)

in your file:

(defparameter *this-file* #.(or *compile-file-truename*
                                *load-truename*))

(format stream "This file is ~s.~%" *this-file*) 

Just some ideas.

frgo

-- 

  Frank Goenninger

  frgo(at)mac(dot)com

  "Don't ask me! I haven't been reading comp.lang.lisp long enough to 
  really know ..."