We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 158d081 commit caf7f53Copy full SHA for caf7f53
demo/handle_stdout/main.go
@@ -6,9 +6,9 @@ import (
6
"os/exec"
7
)
8
9
-// func runSomeShell(args ...string) {
10
-func runSomeShell(args []string) {
11
- cmd := exec.Command("sh", args...)
+func runSomeShell(namestring, args ...string) {
+// func runSomeShell(name string, args []string) {
+ cmd := exec.Command(name, args...)
12
var out, err bytes.Buffer
13
cmd.Stdout = &out
14
cmd.Stderr = &err
@@ -21,6 +21,17 @@ func runSomeShell(args []string) {
21
}
22
23
func main() {
24
- // runSomeShell("./echo.sh", "1", "2", "3")
25
- runSomeShell([]string{"./echo.sh", "1", "2", "3"})
+ runSomeShell("ansible", "jumpserver", "-m ping", "-u root")
+ runSomeShell("sh", "./echo.sh", "a", "b", "c")
26
+ // runSomeShell("sh", []string{"./echo.sh", "a", "b", "c"})
27
28
+
29
+// go run main.go
30
+// ----
31
+// 107.*.*.33 | SUCCESS => {
32
+// "changed": false,
33
+// "ping": "pong"
34
+// }
35
+// 第一个参数为: a 参数个数为: 3
36
+// 第一个参数为: b 参数个数为: 2
37
+// 第一个参数为: c 参数个数为: 1
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments