首页 > 其他 > 详细

go flag.Parse() expect

时间:2021-01-27 22:19:15      阅读:17      评论:0      收藏:0      [点我收藏+]

package main

import (
        "fmt"
        "flag"
        gexpect "github.com/ThomasRooney/gexpect"
)
func main() {
        cmdStr := flag.String("cmd", "", "cmds")
        hostStr := flag.String("host", "", "hoststr")
        passwd := flag.String("p", "", "passwd")
        flag.Parse()

        command := "ssh -o ‘StrictHostKeyChecking no‘ -o ConnectTimeout=2 " + *hostStr + " -a " + *cmdStr
        child, err := gexpect.Spawn(command)
        if err != nil {
                panic(err)
        }
        fmt.Println("-----")
        child.Expect("password:")
        child.SendLine(*passwd)
        child.Interact()
        child.Close()
}

go flag.Parse() expect

原文:https://www.cnblogs.com/ah-firelove/p/14336502.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!