2015-10-13 65 views
2

我對一些腳本使用Common Lisp,並希望執行shell命令run-program。我一直試圖操縱輸出以獲得(output error returncode)的形式的列表,但我只能從運行程序得到輸出或返回代碼。CLISP:從shell命令返回stdout,stderr和retcode

的論點在這裏只給你:output(沒有:error):

有越來越三者的方法嗎?事情是這樣的:

(setf retcode (my-special-cmd "ls" :output stream1 :error stream2)) 
(print (list stream1 stream2 retcode)) 
+0

[Common Lisp中的值函數]的可能重複(http://stackoverflow.com/questions/22795608/values-function-in-common-lisp) – sds

回答

3

run-program回報multiple values。 您可以按照鏈接問題中的說明處理它們。

您鏈接到醫生說:

如果:STREAM指定爲:輸入或:OUTPUT,則返回一個Lisp流。如果:對於:INPUT和:OUTPUT都指定了STREAM,則返回三個Lisp STREAM,如EXT:MAKE-PIPE-IO-STREAM。

因此,你需要的是既

(EXT:MAKE-PIPE-IO-STREAM "ls") 

(ext:run-program "ls" :input :stream :output :stream) 

那麼你將不得不從流讀取返回來獲得命令的輸出。但是,在這種情況下,您將失去退出代碼。

相關問題