2

Chicken Scheme のシステム コマンドから出力を取得するにはどうすればよいですか?

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`
4

2 に答える 2

2

Chicken Scheme に組み込まれている posix ユニットには、call-with-output-pipe があります。utils ユニット (Chicken Scheme にも組み込まれています) の read-all と組み合わせて、シェル コマンドからの出力を読み取ることができます。

#;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-27T05:00:58.207 に答える
1

簡単なグーグル検索を行ったところ、チキンの卵、殻に出くわしました。

これが、卵 のcapture関数を使用することになった方法です。shell

(use shell)
(capture "ls -d ./")
;; -> "./\n"
于 2013-11-26T17:32:44.713 に答える