Skip to content

Instantly share code, notes, and snippets.

@emhaye
Created October 4, 2017 15:33
Show Gist options
  • Save emhaye/48933e2b400f3674e6ef6c56338275f7 to your computer and use it in GitHub Desktop.
Save emhaye/48933e2b400f3674e6ef6c56338275f7 to your computer and use it in GitHub Desktop.

Revisions

  1. emhaye created this gist Oct 4, 2017.
    26 changes: 26 additions & 0 deletions expecting-auto-task.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    Expect auto task to 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
    ```