Reputation: 12873
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?
Upvotes: 1
Views: 1026
Reputation: 52621
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:
system('wget http://www.google.com')
This will "ping" the website, and simply discard the output. It'll be much faster than creating a firefox instance.
Upvotes: 1
Reputation: 40313
You're looking for Process.spawn. The usage would be something like this:
pid = Process.spawn( "firefox http://www.google.com" )
Process.kill( 'QUIT', pid )
Upvotes: 1