【问题标题】:Expect script to wait for Heroku ssh prompt期望脚本等待 Heroku ssh 提示
【发布时间】:2018-02-21 14:38:32
【问题描述】:

我想使用expect 脚本在 Heroku dynos 上运行 SSH 命令(例如:Get IP of Heroku dynos

登录测功机时的确切输出是:

 ▸    heroku-cli: update available from 6.12.9 to 6.14.21-d83c94b
Establishing credentials... done
Connecting to <dyno> on ⬢ <app>...
~ $

我确定更新后第一行会消失。实际发生此身份验证/登录需要几秒钟。

一个简单的期望脚本可以是这样的:

#!/usr/bin/expect
spawn "./ssh_into_heroku"
expect "xxxx"
send "my_command"

我尝试了expect "~ $" { send "my_cmd" }expect "~ $ " { send "my_cmd" },但都没有工作,我不知道如何调试它。

“期望”部分会做些什么来完成这项工作?

【问题讨论】:

标签: heroku expect heroku-cli


【解决方案1】:

您正在等待以空格、美元符号和(我猜)另一个空格结尾的提示。你会使用这个:

set prompt_regex { \$ $}
expect -re $prompt_regex

【讨论】:

    猜你喜欢
    • 2014-10-20
    • 2013-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多