GO語言"os/exec"包中"Cmd.CombinedOutput"類型的用法及代碼示例。
用法:
func(c *Cmd) CombinedOutput()([]byte, error)
CombinedOutput 運行命令並返回其組合的標準輸出和標準錯誤。
例子:
package main
import (
"fmt"
"log"
"os/exec"
)
func main() {
cmd := exec.Command("sh", "-c", "echo stdout; echo 1>&2 stderr")
stdoutStderr, err := cmd.CombinedOutput()
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s\n", stdoutStderr)
}
相關用法
- GO Cmd.Start用法及代碼示例
- GO Cmd.Output用法及代碼示例
- GO Cmd.StdinPipe用法及代碼示例
- GO Cmd.StderrPipe用法及代碼示例
- GO Cmd.Run用法及代碼示例
- GO Cmd.StdoutPipe用法及代碼示例
- GO Chmod用法及代碼示例
- GO CanBackquote用法及代碼示例
- GO CopyN用法及代碼示例
- GO CopyBuffer用法及代碼示例
- GO CreateTemp用法及代碼示例
- GO Cut用法及代碼示例
- GO CIDRMask用法及代碼示例
- GO ContainsRune用法及代碼示例
- GO Cbrt用法及代碼示例
- GO Copysign用法及代碼示例
- GO Compare用法及代碼示例
- GO Cosh用法及代碼示例
- GO Config用法及代碼示例
- GO Count用法及代碼示例
注:本文由純淨天空篩選整理自golang.google.cn大神的英文原創作品 Cmd.CombinedOutput。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。