Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit caf7f53

Browse files
committed
try another CMD
1 parent 158d081 commit caf7f53

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

‎demo/handle_stdout/main.go‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import (
66
"os/exec"
77
)
88

9-
// func runSomeShell(args ...string) {
10-
func runSomeShell(args []string) {
11-
cmd := exec.Command("sh", args...)
9+
func runSomeShell(namestring, args ...string) {
10+
// func runSomeShell(name string, args []string) {
11+
cmd := exec.Command(name, args...)
1212
var out, err bytes.Buffer
1313
cmd.Stdout = &out
1414
cmd.Stderr = &err
@@ -21,6 +21,17 @@ func runSomeShell(args []string) {
2121
}
2222

2323
func main() {
24-
// runSomeShell("./echo.sh", "1", "2", "3")
25-
runSomeShell([]string{"./echo.sh", "1", "2", "3"})
24+
runSomeShell("ansible", "jumpserver", "-m ping", "-u root")
25+
runSomeShell("sh", "./echo.sh", "a", "b", "c")
26+
// runSomeShell("sh", []string{"./echo.sh", "a", "b", "c"})
2627
}
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

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /