gpt4 book ai didi

ruby-on-rails - 执行脚本并在 View 中显示输出/进度 [Ruby/Sinatra(Rails)]

转载 作者:太空宇宙 更新时间:2023-11-03 16:57:04 25 4
gpt4 key购买 nike

我有一个从我的 Sinatra 应用程序中的助手调用的部署脚本。

我想显示一个“正在部署”的 View /页面,然后执行脚本。

然后当脚本完成时,显示一个带有文本框的新页面,其中包含脚本输出。

如何做到这一点?

# update.rb - the main app
helpers do
def run_update
command = "./script.sh"
@ok = system( command )
end
end

post '/version' do
run_update # putting this after the erb call doesnt fix it!?
erb :version
end

目前它在从主页发布帖子后挂起。然后当脚本完成时,它会显示 version.erb 文件。

最佳答案

我想我要找的是 IO#popen

Runs the specified command as a subprocess; the subprocess’s standard input and output will be connected to the returned IO object.

关于ruby-on-rails - 执行脚本并在 View 中显示输出/进度 [Ruby/Sinatra(Rails)],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7187988/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com