我见过this question,但似乎并不适用于此。
使用SBCL,这很好用:
(run-program "/bin/ls" () :output *standard-output*)
这样做:
(run-program "/Applications/Safari.app/Contents/MacOS/Safari" ())
启动Safari窗口。
我可以在我的bin
目录中创建一个bash脚本,其中包含以下内容:
/Applications/Safari.app/Contents/MacOS/Safari
当我从终端运行此bash脚本时,Safari会打开。
但我无法从SBCL内部运行此脚本:
(run-program "/Users/myhome/bin/safariscript" ())
REPL报告:
Couldn't execute "/Users/myhome/bin/safariscript": Exec format error
[Condition of type SIMPLE-ERROR]
该脚本本身可以正常工作。我在没有任何适用于lisp环境的帮助的情况下搜索了这个错误的含义,因此我想知道这里有更广泛的问题吗?
答案 0 :(得分:3)
Shell脚本需要shell-bang行才能通过execve
或使用它的任何内容运行,例如run-program
。因此,您应该将此作为文件的内容使用:
#!/bin/sh
exec /Applications/Safari.app/Contents/MacOS/Safari