我想創建一個exec.Cmd數組,并將它們通過管道連接在一起,以構成一個魷魚驗證器。當文件中的命令沒有參數時,它可以工作。使用參數時,它僅讀取EOF。我檢查了argv數組,它的內容還可以。該代碼的相關部分是:func initCmd(file *os.File) []* exec.Cmd { var cmd [MAX_PROC]* exec.Cmd; var e os.Error // Initialize the commands in the config file environ := os.Environ(); var i int for i=0; i < MAX_PROC; i++ { line := getLine(file) if line == "" { break } parts := strings.Fields(line) cmd[i], e = exec.Run(parts[0], parts[1:], environ, exec.Pipe, exec.Pipe, exec.Pipe) exitOnError(&e) } return cmd[0:i]}有任何想法嗎?謝謝。
- 1 回答
- 0 關注
- 208 瀏覽
添加回答
舉報
0/150
提交
取消