Created
October 18, 2013 11:47
-
-
Save fasheng/7040434 to your computer and use it in GitHub Desktop.
Speed up setup for goagent through expect script.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/expect -f | |
set timeout 60 | |
if {$argc != 2} { | |
set scriptname [lindex [split $argv0 "/"] end] | |
send_user "Usage: $scriptname \"APPID01|APPID02..\" <email>\n" | |
exit | |
} | |
proc getpass pwprompt { | |
set oldmode [stty -echo -raw] | |
send_user "\n$pwprompt" | |
set timeout -1 | |
expect_user -re "(.*)\n" | |
send_user "\n" | |
eval stty $oldmode | |
return $expect_out(1,string) | |
} | |
set appids [lindex $argv 0] | |
set appidlist [split [lindex $argv 0] "|"] | |
set email [lindex $argv 1] | |
set password [getpass "Please enter password: "] | |
set python "python2" | |
set uploader "/usr/share/goagent/server/uploader.zip" | |
set command "$python $uploader" | |
spawn $python $uploader | |
expect -nocase "appid:" {send "$appids\r"} | |
for {set i 0} {$i < [llength $appidlist]} {incr i} { | |
set appid [lindex $appidlist $i] | |
expect -nocase "application:" {send_user "\n\n==> Setup up appid: $appid"} | |
expect -nocase "email:" {send "$email\r"} | |
expect -nocase "password for" {send "$password\r"} | |
expect -nocase "email:" {send "$email\r"} | |
expect -nocase "password for" {send "$password\r"} | |
} | |
expect "上传成功" {send "\r"} | |
interact |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
Then input your password runtime.