【发布时间】:2012-09-17 08:49:43
【问题描述】:
我使用以下函数来运行 shell 命令:
(defun sh (cmd)
#+clisp (shell cmd)
#+ecl (si:system cmd)
#+sbcl (sb-ext:run-program "/bin/sh" (list "-c" cmd) :input nil :output*standard-output*)
#+clozure (ccl:run-program "/bin/sh" (list "-c" cmd) :input nil :output*standard-output*)))
例如,如何为命令python -m CGIHTTPServer指定当前目录?
真诚的!
【问题讨论】:
-
一种方法是在执行之前 cd 到目录,因为脚本将在您的当前目录中运行。
-
(probe-file #P"./")怎么样? -
(probe-file #P"./") 将返回我在执行 shell 命令时要更改的当前目录。现在我使用一个脚本来包装 shell 命令,然后我运行脚本,我可以在其中
cd到任何指定的目录。 -
@wvxvw 你是对的。我需要在调用 sh 函数之前连接命令。谢谢!
标签: common-lisp sbcl ccl ecl