3

例如,如果我想自动授权十六进制用户。就像是

mix hex.user auth
#!/usr/bin/expect -f

expect "Username: "
send -- "$HEX_USERNAME\r"
expect "Password: "
send -- "$HEX_PASSWORD\r"

mix hex.user auth 要求用户名:和密码:但我不认为期望适用于此

4

1 回答 1

4

给定以下脚本:

u = IO.gets("Username: ") |> String.strip
p = IO.gets("Password: ") |> String.strip

IO.puts ""
IO.puts "#{u} - #{p}"

您可以像这样传递输入:

$ export HEX_USERNAME="hexuser"
$ export HEX_PASSWORD="hexpass"
$ echo "$HEX_USERNAME\n$HEX_PASSWORD" | elixir test.exs
Username: Password:
hexuser - hexpass

所以,你可以使用

echo "$HEX_USERNAME\n$HEX_PASSWORD" | mix hex.user auth
于 2015-06-15T04:43:59.843 回答