Skip to content

Instantly share code, notes, and snippets.

@emhaye
Last active October 4, 2017 15:31
Show Gist options
  • Save emhaye/a2e5af125fc5302c21921bf846e65e74 to your computer and use it in GitHub Desktop.
Save emhaye/a2e5af125fc5302c21921bf846e65e74 to your computer and use it in GitHub Desktop.
Expect auto task enter password
example: my password `bojong dev`
```
#!/usr/bin/expect -f
set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn’t run conservatively originally
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}
set timeout -1
spawn sudo apt update
expect -exact ": "
send -- "bojong dev\r"
expect eof
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment