在ruby中执行外部程序并等待其执行 [英] Execute external program in ruby and wait for its execution

查看:147
本文介绍了在ruby中执行外部程序并等待其执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从ruby启动一个外部程序(如excel表),等待其执行。

How do I start an external program (like an excel sheet) from ruby and wait for its execution resp. termination before continuing.

我知道我可以开始使用

system 'start excel "my/path/to/the/sheet"' 

只会启动工作表,然后继续。

but using this will only start the sheet and then continues.

推荐答案

您遇到的问题不在于Ruby,而是启动命令,另一个程序并立即返回。您需要使该命令等待excel完成使用等待标志:

The problem you are having is not with Ruby but the start command, this launches another program and returns immediately. You need to make that command wait for excel to finish using the wait flag:

system('start /wait excel "my/path/to/the/sheet"')

这篇关于在ruby中执行外部程序并等待其执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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