如何从小鸡方案中的系统命令中获取输出?
以下是我通常在NewLISP中所做的事情:
(nth 0 (exec "<COMMAND>"))
;; the `(nth 0...` is just there 'cause I only care about the first element in
;; the list returned by `exec`发布于 2013-11-27 05:00:58
该posix单位,内置到鸡计划,有呼叫-输出-管道.它可以与utils单元中的read-all (也是内置到小鸡方案)结合起来,以读取shell命令的输出:
#;1> (use posix)
#;2> (call-with-input-pipe "echo hello world" read-all)
"hello world\n"http://wiki.call-cc.org/man/4/Unit%20posix#call-with-output-pipe
http://wiki.call-cc.org/man/4/Unit%20utils#read-all
发布于 2013-11-26 17:32:44
我做了一个快速的谷歌搜索,我偶然发现了鸡蛋,壳。
下面是我如何使用来自capture鸡蛋的shell函数。
(use shell)
(capture "ls -d ./")
;; -> "./\n"https://stackoverflow.com/questions/20224030
复制相似问题