[Openmcl-devel] Why cannot i use the shebang ?

Joshua Kordani jkordani at lsa2.com
Thu Aug 1 20:57:54 PDT 2013


Pascal is pulling your leg....

You are mixing metaphors.  Your original script says that you want to use the shell to execute ccl, passing a script to load once starting up the image.

Your problem is that you are passing the current script that you're executing!!!!!  You have a shell script, and are trying to feed it to ccl as a lisp source file.  Pascal is right, in that the error message is very clear about why the ccl program has a problem with your input file.  The overarching problem is that you're passing the ccl program the wrong kind of file.  The metaphors you are mixing are "what do I need to do to start ccl" and "what do I need to do to run my code"

Just because you call your file .lisp doesn't mean that the shell is going to read the script and pass it to the proper program to execute.  Nay, with a #!/bin/sh, the script file you made is going to pass to /bin/sh for execution first, and the first command that sh evaluates will be your call to execute ccl.  So far so good.

What you need to do is separate everything else that is lisp code into its own file, or find a #! line that passes the script to ccl, like #!/home/username/ccl/fx86cl -Q -l
(your lisp script here)

So you either have two files:
start-program.sh:
#!/bin/sh

exec ~/ccl/fx86cl -Q -n -l $1
EOF

and another file
my-lisp-program.lisp:
(ql:quickload .....
EOF

and then you make your start-program.sh executable with chmod +x, 
then to run everything,
/path/to/start-program.sh /path/to/my-lisp-program.lisp
this passes my-lisp-program.lisp as the first argument to your start-program.sh

the other way (and I haven't tried this, but it works like this with newlisp):
lisp-program-as-shell-script.lisp:
#!/path/to/ccl/fx86cl -Q -n -l
(ql:quickload....
EOF

make lisp-program.... executable with chmod +x. and maybe this will work.

With the separation into two files, you get the ability to start your program on any OS (as long as your lisp code is platform independent)
because to migrate to windows, you make a batch file that looks like this
start-program.bat:
start c:\path\to\ccl\fx86cl.exe -Q -n -l %%1  <---my batch foo is weak, but you get the idea

While your lisp-program.lisp file stays the same!!!
Now on windows you invoke your program with
start-program.bat my-lisp-program.lisp

I hope this has been illuminating.  Sorry to spoil your fun Pascal :-)

Josh Kordani


More information about the Openmcl-devel mailing list