ssh/example/runetl/main.go

32 lines
622 B
Go
Raw Normal View History

2018-12-19 14:33:31 +08:00
package main
import (
"fmt"
"blacktea.vip.cpolar.top/OrgGo/ssh"
2018-12-19 14:33:31 +08:00
)
func main() {
2019-03-12 17:12:42 +08:00
config := ssh.Default.WithHost("15.14.12.153").WithPassword("HR2018!!")
2018-12-19 14:33:31 +08:00
// config.Host = "15.14.12.153"
client, err := ssh.New(config)
// client, err := ssh.NewClient("localhost", "22", "root", "ubuntu")
if err != nil {
// panic(err)
fmt.Println("连接失败,按Enter键退出!")
fmt.Scanln()
}
defer client.Close()
err = client.Exec("sh /root/shetl/etl.sh")
if err != nil {
fmt.Println(err)
// panic(err)
fmt.Println("执行失败,按Enter键退出!")
fmt.Scanln()
}
// fmt.Printf("Uptime: %s\n", output)
}