I'm working on the interface to LiveGraphics3D (Java applet for dynamic 3D graphics) that I mentioned earlier on the list, and I've hit a cross-platform problem. I want to allow the option of popping up a browser or opening the file in a browser automatically. On Unix, the following (stolen from help.start()) works: system(paste(browser, " -remote \"openURL(", url, ")\" 2>/dev/null || ", browser, " ", url, " &", sep = "")) If I want to do this in Windows, options("browser") is NULL. (For now I'm hardcoding browser to "C:/PROGRA~1/INTERN~1/IEXPLORE.EXE", but this clearly isn't a general solution.) The syntax of the call is also different (IE at least appears to require just the file name, "file:/" just seems to confuse it). I don't know how to start a browser in the background, or do the equivalent of -remote ... help.start() is considerably more internalized on Windows, so I'm not getting much useful there. Here's what I'm doing now: mach <- machine() if (mach=="Unix") { url <- paste("file:",file.path(getwd(),fn),sep="") system(paste(browser, " -remote \"openURL(", url, ")\" 2>/dev/null || ", browser, " ", url, " &", sep = "")) } else if (mach=="Windows") { system(paste(browser,file.path(getwd(),fn))) } } Is there a different idiom I should be using for Windows? I suppose it's all completely different for the Mac too ... Might it be possible to standardize this interface? thanks, Ben Bolker -- 318 Carr Hall bolker@zoo.ufl.edu Zoology Department, University of Florida http://www.zoo.ufl.edu/bolker Box 118525 (ph) 352-392-5697 Gainesville, FL 32611-8525 (fax) 352-392-3704 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Prof Brian D Ripley
2001-Oct-06 14:51 UTC
[Rd] Difficulties lauching HTML pages on Unix (was calling browser in Windows)
I changed the title, because this is not about browser() but about HTML viewers, and the problem is on Unix not Windows. On Tue, 2 Oct 2001, Ben Bolker wrote:> I'm working on the interface to LiveGraphics3D (Java applet for dynamic > 3D graphics) that I mentioned earlier on the list, and I've hit a > cross-platform problem.I think it's a within-Unix-platform problem, mainly. The other two ports have a simple procedure: it's Unix/Linux where the problems arise.> I want to allow the option of popping up a browser or opening the file > in a browser automatically. On Unix, the following (stolen from > help.start()) works: > > system(paste(browser, " -remote \"openURL(", url, ")\" 2>/dev/null || ", > browser, " ", url, " &", sep = ""))And last time we tested this that only works if the browser is netscape 4.7x, so the freedom is illusory.> If I want to do this in Windows, options("browser") is NULL. (For now I'm > hardcoding browser to "C:/PROGRA~1/INTERN~1/IEXPLORE.EXE", but this > clearly isn't a general solution.) The syntax of the call is also > different (IE at least appears to require just the file name, "file:/" > just seems to confuse it). I don't know how to start a browser in the > background, or do the equivalent of -remote ... help.start() is > considerably more internalized on Windows, so I'm not getting much useful > there.Look at help, just as you should for Unix.> Here's what I'm doing now: > > mach <- machine() > if (mach=="Unix") { > url <- paste("file:",file.path(getwd(),fn),sep="") > system(paste(browser, " -remote \"openURL(", url, ")\" 2>/dev/null || > ", > browser, " ", url, " &", sep = "")) > } > else if (mach=="Windows") { > system(paste(browser,file.path(getwd(),fn))) > } > } > > > Is there a different idiom I should be using for Windows??shell.exec> I suppose it's all completely different for the Mac too ...(A better way to say this is that is completely different under Unix, but Mac and Windows are similar.)> Might it be possible to standardize this interface?Yes, one might be able to persuade the Unix world to agree on one .... What help() does does not even work with Netscape 6.01 (and I have yet to try it with 6.1). -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._