Skip to content
/ expect Public

Package expect is a Go version of the classic TCL Expect.

License

Notifications You must be signed in to change notification settings

cedarwu/expect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

expect

Package expect is a Go version of the classic TCL Expect.

Usage

example

	// spawn `ssh 127.0.0.1` with default timeout=3s
	e, err := expect.Spawn("ssh 127.0.0.1", time.Second*3)
	if err != nil {
		panic(err)
	}

	// expect for `password:` with default timeout
	_, err = e.Expect("password:", -1)
	if err != nil {
		panic(err)
	}

	// send string with newline
	_, err = e.SendLine("passwd")
	if err != nil {
		panic(err)
	}

	// give control to the interactive user
	err = e.Interact()
	if err != nil {
		panic(err)
	}

	// wait for finish of spawned process
	err = e.Wait()
	if err != nil {
		panic(err)
	}

About

Package expect is a Go version of the classic TCL Expect.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages