-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.go
39 lines (36 loc) · 1.05 KB
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import (
"fmt"
"os"
"os/exec"
"strings"
)
func main() {
args := os.Args
Bandwidth := args[1]
cmd := exec.Command("sh", "-c", fmt.Sprintf("cat ip.config"))
stdout, _ := cmd.CombinedOutput()
output := string(stdout)
ServerIP := strings.Fields(output)[0]
print(ServerIP)
// cmd = exec.Command("sh", "-c", fmt.Sprintf("ps"))
// stdout, _ = cmd.CombinedOutput()
// output = string(stdout)
// lines := strings.Split(output, "\n")
// for _, line := range lines {
// if len(line) != 0 && strings.Contains(line, "iperf3 -c") {
// words := strings.Fields(line)
// for _, word := range words {
// println(word)
// }
// cmd := exec.Command("sh", "-c", fmt.Sprintf("kill -9 %s", words[0]))
// stdout, _ := cmd.CombinedOutput()
// output = string(stdout)
// time.Sleep(time.Duration(1) * time.Second)
// break
// }
// }
cmd = exec.Command("sh", "-c", fmt.Sprintf("nohup iperf3 -c %s -b %s -p 5202 –i 1 -t 10000 &", ServerIP, Bandwidth))
cmd.Run()
}
// CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o client client.go