如何使用 Linux 实例化/运行 Ruby 程序(使用 Watir)?

发布于 2024-08-20 12:14:22 字数 480 浏览 2 评论 0原文

场景:

我在 Win XP 计算机上映射了网络驱动器,然后双击 .bat 文件来执行此 Ruby 脚本。 .rb 和 .bat 文件驻留在该网络驱动器上。

批处理文件如下:

Z: cd Z:\ABC\StatusCheck\ "C:\Program Files\Ruby\Bin\ruby.exe" Z:\ABC\StatusCheck\rubyScript.rb 6

Ruby 文件如下:

require 'watir'
rec = File.open("list.txt", "r")
ie = Watir::IE.start()
***Other processing here***

我的问题:如何使用 Linux 实例化此批处理文件(当我在家时,因为我无法远程访问这台机器,我想从终端运行 .rb 文件)?

希望我说得有道理。我真的很感谢你们花时间!谢谢你!

Scenario :

I mapped a network drive on a Win XP machine and I double click a .bat file to execute this Ruby script. The .rb and .bat file reside on this networked drive.

The batch file is as follows :

Z:
cd Z:\ABC\StatusCheck\
"C:\Program Files\Ruby\Bin\ruby.exe" Z:\ABC\StatusCheck\rubyScript.rb 6

The Ruby file is as follows :

require 'watir'
rec = File.open("list.txt", "r")
ie = Watir::IE.start()
***Other processing here***

My Question : How do I instantiate this batch file using Linux (when I am at home cos I cannot remote into to this machine. I want to run the .rb file from the terminal)?

Hope I made sense. I really appreciate your time guys! Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半夏半凉 2024-08-27 12:14:22

在 Linux 上运行它不需要任何批处理文件。您需要做的就是直接运行脚本

ruby rubyScript.rb

或者添加

#!/usr/bin/env ruby

到 ruby​​Script.rb 顶部并使其可执行,然后就可以直接运行。

然而,你更大的问题是你正在使用 watir 来自动化 IE,这显然不适用于 Linux,因此你需要更改它以使用其他浏览器。

You don't need any batch file to run this on linux. All you need to do is run the script directly with

ruby rubyScript.rb

or add

#!/usr/bin/env ruby

to the top of rubyScript.rb and make it executable, then you can run directly.

However, your bigger problem is that you are using watir to automate IE, which obviously won't work on Linux, so you'll need to change it to use another browser.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文