Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sh7ning/1139d1a62c362528212a00d9e7b61589 to your computer and use it in GitHub Desktop.
Save sh7ning/1139d1a62c362528212a00d9e7b61589 to your computer and use it in GitHub Desktop.
auto-login-mysql.go
package main

import (
	"fmt"

	"github.com/ThomasRooney/gexpect"
)

func main() {
	child, err := gexpect.Spawn(fmt.Sprintf("/usr/local/opt/mysql-client/bin/mysql -h 127.0.0.1 -u %s -p", "root"))
	if err != nil {
		panic(err)
	}
	child.Expect("Enter password")
	child.SendLine("123123\n")
	child.Expect("mysql>")
	fmt.Printf("mysql>")
	child.Interact()
	fmt.Printf("Done \n")
	child.Close()
}
@sh7ning
Copy link
Author

sh7ning commented Oct 25, 2019

ssh 有个小bug...跳板机不能展示出有权限的服务器列表....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment