[Rails] Invoking browser from Ruby script with URL argument: How?
Hi,
I've got the folowing script:
require "fileutils"
path = "K:/_Utilities/Apache/xampp/"
FileUtils::cd path
names = Dir.glob("**/index.html")
(0..4).each { |i|
name = names[i]
address = "file://" + path + name
puts address
exec address
}
It runs fine without line 10, "exec address", and produces:
file://K:/_Utilities/Apache/xampp/apache/htdocs/index.html
file://K:/_Utilities/Apache/xampp/htdocs/index.html
file://K:/_Utilities/Apache/xampp/htdocs/restricted/index.html
file://K:/_Utilities/Apache/xampp/licenses/gd/index.html
file://K:/_Utilities/Apache/xampp/php/docs/Structures_Graph/docs/html/index.html
But with line 10 active, I hang with:
K:\>ruby K:\_Projects\Ruby\_Ruby_Tests\TestDirTraversal
\TestDirTraversal.rb
file://K:/_Utilities/Apache/xampp/apache/htdocs/index.html
K:/_Projects/Ruby/_Ruby_Tests/TestDirTraversal/TestDirTraversal.rb:
10:in `exec': Invalid argument - file://K:/_Utilities/Apache/xampp/apache/htdocs/in
dex.html (Errno::EINVAL)
from K:/_Projects/Ruby/_Ruby_Tests/TestDirTraversal/
TestDirTraversal.rb:10:in `block in <main>'
[snip]
Of course, if I pasted these addresses on successive lines of Word
(with space characters appended to each), I'd have a series of
hyperlinks that could control-click to invoke the respective URLs in
Firefox.
Is there a way I can repair the code here to achieve the equivalent
effect with Ruby?
Thanks in advance for any education you may offer,
Richard
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home