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
|
package main
import (
"fmt"
"time"
_ "gmsec/internal/routers" // debug模式需要添加[mod]/routers 注册注解路由
"github.com/xxjwxc/public/myssh"
)
func main() {
c, err := myssh.New("127.0.0.1", "ubuntu", "123456", 22)
if err != nil {
fmt.Println("err", err)
}
output, err := c.Run("free -h")
fmt.Printf("%v\n%v", output, err) // 返回字符串
time.Sleep(1 * time.Second)
// c.RunTerminal("top") 交互式
// time.Sleep(1 * time.Second)
c.Terminal() // 进入
}
|