是否有可能编写连接到Heroku并运行Ruby命令的shell命令? [英] Is it possible to write a shell command that connects to Heroku and runs a Ruby command?

查看:120
本文介绍了是否有可能编写连接到Heroku并运行Ruby命令的shell命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在OSX上编写以下脚本?

  heroku运行控制台
加载'init.rb'

以下是 不是 工作:

  alias'heroku_init = heroku run console; loadinit.rb'

看起来shell必须等待Heroku控制台连接,或者需要一种方法将 load 命令发送到Heroku控制台而不是bash shell。

解决

-f
set timeout -1
spawn heroku console
expectirb(main):001:0>
sendloadapp / init.rb'\r
interact

另外,可以用别名完成:

 别名'hc = heroku运行控制台 -  -r ./app/ init.rb'


Is it possible to script the following on OSX?

heroku run console
load 'init.rb'

The following does not work:

alias 'heroku_init=heroku run console; load "init.rb"'

It seems that the shell has to wait for the Heroku console to connect, or needs a way to send the load command to the Heroku console instead of the bash shell.

解决方案

Big ups to camilo-santana for the answer:

#!/usr/bin/expect -f
set timeout -1
spawn heroku console
expect "irb(main):001:0>"
send "load 'app/init.rb'\r"
interact

Also, can be done with an alias:

alias 'hc=heroku run console -- -r ./app/init.rb'

这篇关于是否有可能编写连接到Heroku并运行Ruby命令的shell命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆