[Rd] Revision of shell.exec?

Simon Urbanek simon.urbanek at r-project.org
Wed Sep 14 22:56:25 CEST 2011


On Sep 14, 2011, at 4:44 PM, Dirk Eddelbuettel wrote:

> 
> On 14 September 2011 at 16:22, Simon Urbanek wrote:
> | 
> | On Sep 14, 2011, at 4:15 PM, Brian Oney wrote:
> | 
> | > Hi there,
> | > new idea (at 10 at night). All the emails keep me thinking (btw thanks for all the feedback).
> | > What does this do on linux?
> | > 
> | > getOption("pdfviewer")
> | > ### I got this idea from: getS3method("print","vignette")
> | > 
> | 
> | It gives you the detected PDF viewer as I was explaining (essentially R_PDFVIEWER). The two detected settings I was referring to are R_PDFVIEWER (for PDF) and R_BROWSER (for URLs) which are the initial settings for the "pdfviewer" and "browser" options.
> | 
> | Note that it's what it say it is - R_PDFVIEWER is usually something like acroread or evince so not particularly useful for your purpose ...
> 
> R> getOption("pdfviewer")
> [1] "/usr/bin/xdg-open"
> R> 
> 
> We've had that as xdg-open in Debian / Ubuntu for a while now...
> 

Yes, but that's merely a side-effect. For example on Ubuntu (R from sources) I get

gis:~$ Rscript -e 'cat(getOption("pdfviewer"),"\n")'
/usr/bin/X11/evince 

because xdg-open is not installed by default. My point is that the setting is meant for something else, so misappropriating it, although possible, may not be wise. If you really want to go down that alley, you could use some logic like

if (identical(getOption("pdfviewer"), getOption("browser"))) { # better chance that it's something that can open things universally
} else { ## well, bad luck ... }

That will work on Macs and possibly on OSes that have generic open commands ... (but is not guaranteed to ...).

Cheers,
Simon



> Dirk
> 
> -- 
> New Rcpp master class for R and C++ integration is scheduled for 
> San Francisco (Oct 8), more details / reg.info available at
> http://www.revolutionanalytics.com/products/training/public/rcpp-master-class.php
> 
> 



More information about the R-devel mailing list