cmucl:仅退出运行程序输出进程

时间:2017-12-06 05:42:07

标签: lisp common-lisp

我正在debian伸展并从稳定的存储库安装CMUCL。在尝试以下

(run-program "sh" '("ls") :output T)

我得到了

#<process 2845 :EXITED>

没有预期的输出。有什么帮助吗?

1 个答案:

答案 0 :(得分:3)

阅读ls(1)dash(1)&amp; bash(1)。请注意,POSIX /bin/sh通常是其中一个的符号链接(通常为dash,有时为bash)。请注意PATH variable的作用(例如shellsexecvp(3))。 system(3)正在/bin/sh使用-csh(假设它是POSIX shell)需要-c将字符串解释为命令。< / p>

你可以尝试

  (run-program "/bin/ls" nil :output t)

  (run-program "/bin/sh" '("-c" "ls") :output t)

你可能working directory中没有ls(但PATH中的其他地方;在POSIX上应该是/bin/ls)和{{1}不是shell script,而是一些ELF可执行文件(在Linux上;在大多数Unix上,它是一些executable并且不是脚本)。因此,/bin/ls(或/bin/sh ls)无法按照您的意愿运作。

要运行sh ls,无需启动shell!您可能不需要为此目的(列出文件)分配ls进程,因为您可以opendir(3) readdir(3) stat(2) closedir(3)调用{{{ 3}}(或找到FFI包执行此操作)。

PS。我使用some来测试这些。

相关问题