使用 Ruby 关闭应用程序
我想知道如何从 Ruby 关闭浏览器。我目前知道如何打开:
system('firefox http://www.google.com')
How do I close the same browser window?
I was wondering how to close my browser from Ruby. I currently know how a way to open by:
system('firefox http://www.google.com')
How do I close the same browser window?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您正在寻找 Process.spawn。用法是这样的:
You're looking for Process.spawn. The usage would be something like this:
您似乎只是想通过打开浏览器来“ping”http://www.google.com,然后然后将其关闭。
有更快、更简单的方法可以做到这一点。在您的情况下,最简单的一种(因为您已经设置了命令行)是使用 curl 或 wget:
这将“ping”网站,并简单地丢弃输出。它会比创建 Firefox 实例快得多。
It seems that you are just trying to "ping" http://www.google.com by opening a browser and then closing it up.
There are faster, easier ways to do that. The simplest one in your case (since you already have a command line set up) would be using curl or wget:
This will "ping" the website, and simply discard the output. It'll be much faster than creating a firefox instance.