RichardOnRails
2011-Aug-08 18:10 UTC
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
7stud --
2011-Aug-08 19:28 UTC
Re: Invoking browser from Ruby script with URL argument: How?
exec([env,] command... [,options]) Replaces the current process by running the given external command but file://K:/_Utilities/Apache/xampp/apache/htdocs/index.html isn''t a command. -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
7stud --
2011-Aug-08 20:21 UTC
Re: Invoking browser from Ruby script with URL argument: How?
http://stackoverflow.com/questions/2159735/how-to-let-ruby-call-default-browser-to-open-localfile -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law
2011-Aug-08 20:32 UTC
Re: Invoking browser from Ruby script with URL argument: How?
On 8 August 2011 19:10, RichardOnRails <RichardDummyMailbox58407-gP6xRNRnnqSxhq/XJNNIW0EOCMrvLtNR@public.gmane.org> wrote:> 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 addressPossibly exec "firefox #{address}" Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
RichardOnRails
2011-Aug-08 20:58 UTC
Re: Invoking browser from Ruby script with URL argument: How?
Hi 7-stud, Long time no "see". Thanks for looking into my question.> file://K:/_Utilities/Apache/xampp/apache/htdocs/index.html > > isn''t a command.Yeah, I know, but my question is how to repair my code so that it works. Or more specifically, what command can I take which accepts the text of a URL as an argument and invokes my browser with that command as an argument? Do you have a further idea? I greatly appreciate learning any other idea you might have on the question. Best wishes, Richard On Aug 8, 3:28 pm, 7stud -- <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> exec([env,] command... [,options]) > Replaces the current process by running the given external command > > but > > file://K:/_Utilities/Apache/xampp/apache/htdocs/index.html > > isn''t a command. > > -- > Posted viahttp://www.ruby-forum.com/.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
RichardOnRails
2011-Aug-08 21:08 UTC
Re: Invoking browser from Ruby script with URL argument: How?
Colin,> exec "firefox #{address}"You''re my hero!! I couldn''t think of what command I could use to invoke the browser on my machine. I wish I had possessed enough imagination to at least try that idea before posting my question. I did harbor the fancy of poking through Rails source code, thinking I might find a clue there. But that seemed daunting to me. Best wishes, Richard On Aug 8, 4:32 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 8 August 2011 19:10, RichardOnRails > > <RichardDummyMailbox58...-gP6xRNRnnqSxhq/XJNNIW0EOCMrvLtNR@public.gmane.org> wrote: > > 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 > > Possibly > exec "firefox #{address}" > > Colin-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Frederick Cheung
2011-Aug-08 21:39 UTC
Re: Invoking browser from Ruby script with URL argument: How?
On Aug 8, 10:08 pm, RichardOnRails <RichardDummyMailbox58...-FtJgd9dCuO3JTKoYRCtP1UEOCMrvLtNR@public.gmane.org> wrote:> Colin, > > > exec "firefox #{address}" >I don''t think this would work on a max, since GUI apps aren''t normally in $PATH. You might be interested in the launchy gem. Fred> You''re my hero!! I couldn''t think of what command I could use to > invoke the browser on my machine. I wish I had possessed enough > imagination to at least try that idea before posting my question. I > did harbor the fancy of poking through Rails source code, thinking I > might find a clue there. But that seemed daunting to me. > > Best wishes, > Richard > > On Aug 8, 4:32 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > > > On 8 August 2011 19:10, RichardOnRails > > > <RichardDummyMailbox58...-gP6xRNRnnqSxhq/XJNNIW0EOCMrvLtNR@public.gmane.org> wrote: > > > 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 > > > Possibly > > exec "firefox #{address}" > > > Colin-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
RichardOnRails
2011-Aug-08 22:54 UTC
Re: Invoking browser from Ruby script with URL argument: How?
Hi Fred, I''m happy our paths crossed again. The launchy gem looks cool. The page I found it on also advertised Process Explorer from SysInternals that replaces Window''s StartMenu ... something I''ve wanted for a long time. So, it''s a double-hitter. Thanks and best wishes, Richard On Aug 8, 5:39 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Aug 8, 10:08 pm, RichardOnRails > > <RichardDummyMailbox58...-FtJgd9dCuO3JTKoYRCtP1UEOCMrvLtNR@public.gmane.org> wrote: > > Colin, > > > > exec "firefox #{address}" > > I don''t think this would work on a max, since GUI apps aren''t normally > in $PATH. You might be interested in the launchy gem. > > Fred > > > > > > > > > You''re my hero!! I couldn''t think of what command I could use to > > invoke the browser on my machine. I wish I had possessed enough > > imagination to at least try that idea before posting my question. I > > did harbor the fancy of poking through Rails source code, thinking I > > might find a clue there. But that seemed daunting to me. > > > Best wishes, > > Richard > > > On Aug 8, 4:32 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > > On 8 August 2011 19:10, RichardOnRails > > > > <RichardDummyMailbox58...-gP6xRNRnnqSxhq/XJNNIW0EOCMrvLtNR@public.gmane.org> wrote: > > > > 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 > > > > Possibly > > > exec "firefox #{address}" > > > > Colin-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
7stud --
2011-Aug-08 23:32 UTC
Re: Invoking browser from Ruby script with URL argument: How?
RichardOnRails wrote in post #1015562:> Hi 7-stud, > > Long time no "see". Thanks for looking into my question. > >> file://K:/_Utilities/Apache/xampp/apache/htdocs/index.html >> >> isn''t a command. > > Yeah, I know, but my question is how to repair my code so that it > works. Or more specifically, what command can I take which accepts > the text of a URL as an argument and invokes my browser with that > command as an argument? > > Do you have a further idea? >Well, I provided a link. -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Jarin Udom
2011-Aug-09 00:25 UTC
Re: Invoking browser from Ruby script with URL argument: How?
On a Mac, you don''t need launchy, just do: open http://example.com/whatever -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/nCJTNPPEys0J. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2011-Aug-09 09:30 UTC
Re: Invoking browser from Ruby script with URL argument: How?
On Aug 9, 1:25 am, Jarin Udom <jarin.u...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On a Mac, you don''t need launchy, just do: > > openhttp://example.com/whateverYou don''t need launchy on any platform but it takes away from you the hassle of deciding which strategy to use for a given environment. Fred -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
RichardOnRails
2011-Aug-09 14:18 UTC
Re: Invoking browser from Ruby script with URL argument: How?
Hi again,>> Do you have a further idea? > > Well, I provided a link.Thanks for that link in your second post. I only received it about an hour after your original response, which only pointed out that I lacked a function reference. Hence my request for further idea(s). Now I have a wealth of good solutions: Yours, Colin''s and Fred''s Thanks to you and them, Richard On Aug 8, 7:32 pm, 7stud -- <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> RichardOnRails wrote in post #1015562: > > > Hi 7-stud, > > > Long time no "see". Thanks for looking into my question. > > >> file://K:/_Utilities/Apache/xampp/apache/htdocs/index.html > > >> isn''t a command. > > > Yeah, I know, but my question is how to repair my code so that it > > works. Or more specifically, what command can I take which accepts > > the text of a URL as an argument and invokes my browser with that > > command as an argument? > > > Do you have a further idea? > > Well, I provided a link. > > -- > Posted viahttp://www.ruby-forum.com/.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.