Re: [Rd] Revision of shell.exec?
On Wed, 14 Sep 2011, Simon Urbanek wrote: On Sep 14, 2011, at 11:08 AM, Brian Oney wrote: Hi Steve, a quick look at browseURL will tell you that indeed system or shell.exec (on a windows platform) is used to open up a URL. The open part of the proposed function was written to work on a Mac. Because Mac is a unix platform, I assumed that the function open would be omnipresent on unix platforms, my mistake. Well, the problem is that open is unfortunately mapped to openvt on Linux systems which is a quite obscure anachronism. But since Linux is Linux there is no standard way to open a file, so it doesn't really matter ;) -- xdg-utils come closest to what one may call standard but on many systems they are not installed by default (in fact on none of the Linux machines I have around). For URLs R does the hard work to try to figure out what to do with them (it also does the same for PDFs), but you may end up opening things in a browser although that's not what you had in mind. Well I guess, we know how to make to work on a mac. Yes, open works very well on Macs and is extremely useful (I use it all the time - among other things you can use it with directories to browse them...) - it is still beyond me why other unices don't bother ... They do: as 'open' is already taken, they use xdg-open. I am not at all convinced base R needs any such addition: we manage to open anything R itself needs with the existing code. Cheers, Simon I will make the transition to Linux and get back to this in a while, ok? Cheers, Brian On 9/14/2011 2:50 PM, Stephen Weston wrote: 2011/9/14 Uwe Liggeslig...@statistik.tu-dortmund.de: On 14.09.2011 12:27, Brian Oney wrote: Hi List, I hope this is correct list to propose function extensions, sorry if not. I am preparing for a (hopefully painless) migration to linux. As far as I am aware of, the function shell.exec only comes with the windows version. I think this is a handy little function and would like to see my scripts work when I migrate. May I propose something (like the following)? open.file- function(file) { if(.Platform$OS.type==windows) {shell.exec(file)} else {system(paste(open ,file))} } Or just a small addition to the shell.exec function and no new named function. Hope the idea isn't received as too stupid. What is open supposed to do on a non-Windows machine? I do not have it on the only Linux installation I looked at now, hence we obviously cannot assume it exists on an arbitrary installation. I think the nearest equivalent for those running Gnome or KDE may be xdg-open. So there would probably need to be a new option for specifying the appropriate command. Personally, I am more inclined to use system for executing commands, and browseURL for opening documents. browseURL even uses xdg-open in my R installation on my Linux machine. - Steve Best, Uwe Ligges Cheers, Brian __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- Brian D. Ripley, rip...@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 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Revision of shell.exec?
On 14.09.2011 22:15, 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) On windows, (an advantage...) somebody wrote a little program open.exe that comes stock with an R-installation, which somehow accesses the file system to find the default program to for a certain file type. I am guessing this little beauty is the engine of shell.exec. No. It simply uses ShellExecute() in windows.h, i.e. defined in Microsoft's Windows User Interface.´: http://msdn.microsoft.com/en-us/library/bb762153%28v=vs.85%29.aspx Uwe Ligges (An honest) cheers, Brian On 9/14/2011 7:49 PM, Simon Urbanek wrote: On Sep 14, 2011, at 1:10 PM, Henrik Bengtsson wrote: On Wed, Sep 14, 2011 at 8:35 AM, Simon Urbanek simon.urba...@r-project.org wrote: On Sep 14, 2011, at 11:08 AM, Brian Oney wrote: Hi Steve, a quick look at browseURL will tell you that indeed system or shell.exec (on a windows platform) is used to open up a URL. The open part of the proposed function was written to work on a Mac. Because Mac is a unix platform, I assumed that the function open would be omnipresent on unix platforms, my mistake. Well, the problem is that open is unfortunately mapped to openvt on Linux systems which is a quite obscure anachronism. But since Linux is Linux there is no standard way to open a file, so it doesn't really matter ;) -- xdg-utils come closest to what one may call standard but on many systems they are not installed by default (in fact on none of the Linux machines I have around). For URLs R does the hard work to try to figure out what to do with them (it also does the same for PDFs), but you may end up opening things in a browser although that's not what you had in mind. Well I guess, we know how to make to work on a mac. Yes, open works very well on Macs and is extremely useful (I use it all the time - among other things you can use it with directories to browse them...) - it is still beyond me why other unices don't bother ... Apple probably patented it. I'm pretty sure it's at least as old as NeXT so that's way before the abuse of software patents ;) - but who knows ... Cheers, S /Henrik Cheers, Simon I will make the transition to Linux and get back to this in a while, ok? Cheers, Brian On 9/14/2011 2:50 PM, Stephen Weston wrote: 2011/9/14 Uwe Liggeslig...@statistik.tu-dortmund.de: On 14.09.2011 12:27, Brian Oney wrote: Hi List, I hope this is correct list to propose function extensions, sorry if not. I am preparing for a (hopefully painless) migration to linux. As far as I am aware of, the function shell.exec only comes with the windows version. I think this is a handy little function and would like to see my scripts work when I migrate. May I propose something (like the following)? open.file- function(file) { if(.Platform$OS.type==windows) {shell.exec(file)} else {system(paste(open ,file))} } Or just a small addition to the shell.exec function and no new named function. Hope the idea isn't received as too stupid. What is open supposed to do on a non-Windows machine? I do not have it on the only Linux installation I looked at now, hence we obviously cannot assume it exists on an arbitrary installation. I think the nearest equivalent for those running Gnome or KDE may be xdg-open. So there would probably need to be a new option for specifying the appropriate command. Personally, I am more inclined to use system for executing commands, and browseURL for opening documents. browseURL even uses xdg-open in my R installation on my Linux machine. - Steve Best, Uwe Ligges Cheers, Brian __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Revision of shell.exec?
On 11-09-15 4:27 AM, Uwe Ligges wrote: On 14.09.2011 22:15, 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) On windows, (an advantage...) somebody wrote a little program open.exe that comes stock with an R-installation, which somehow accesses the file system to find the default program to for a certain file type. I am guessing this little beauty is the engine of shell.exec. No. It simply uses ShellExecute() in windows.h, i.e. defined in Microsoft's Windows User Interface.´: http://msdn.microsoft.com/en-us/library/bb762153%28v=vs.85%29.aspx Yes, and open.exe is a simple command line wrapper for that call. Duncan Murdoch Uwe Ligges (An honest) cheers, Brian On 9/14/2011 7:49 PM, Simon Urbanek wrote: On Sep 14, 2011, at 1:10 PM, Henrik Bengtsson wrote: On Wed, Sep 14, 2011 at 8:35 AM, Simon Urbanek simon.urba...@r-project.org wrote: On Sep 14, 2011, at 11:08 AM, Brian Oney wrote: Hi Steve, a quick look at browseURL will tell you that indeed system or shell.exec (on a windows platform) is used to open up a URL. The open part of the proposed function was written to work on a Mac. Because Mac is a unix platform, I assumed that the function open would be omnipresent on unix platforms, my mistake. Well, the problem is that open is unfortunately mapped to openvt on Linux systems which is a quite obscure anachronism. But since Linux is Linux there is no standard way to open a file, so it doesn't really matter ;) -- xdg-utils come closest to what one may call standard but on many systems they are not installed by default (in fact on none of the Linux machines I have around). For URLs R does the hard work to try to figure out what to do with them (it also does the same for PDFs), but you may end up opening things in a browser although that's not what you had in mind. Well I guess, we know how to make to work on a mac. Yes, open works very well on Macs and is extremely useful (I use it all the time - among other things you can use it with directories to browse them...) - it is still beyond me why other unices don't bother ... Apple probably patented it. I'm pretty sure it's at least as old as NeXT so that's way before the abuse of software patents ;) - but who knows ... Cheers, S /Henrik Cheers, Simon I will make the transition to Linux and get back to this in a while, ok? Cheers, Brian On 9/14/2011 2:50 PM, Stephen Weston wrote: 2011/9/14 Uwe Liggeslig...@statistik.tu-dortmund.de: On 14.09.2011 12:27, Brian Oney wrote: Hi List, I hope this is correct list to propose function extensions, sorry if not. I am preparing for a (hopefully painless) migration to linux. As far as I am aware of, the function shell.exec only comes with the windows version. I think this is a handy little function and would like to see my scripts work when I migrate. May I propose something (like the following)? open.file- function(file) { if(.Platform$OS.type==windows) {shell.exec(file)} else {system(paste(open ,file))} } Or just a small addition to the shell.exec function and no new named function. Hope the idea isn't received as too stupid. What is open supposed to do on a non-Windows machine? I do not have it on the only Linux installation I looked at now, hence we obviously cannot assume it exists on an arbitrary installation. I think the nearest equivalent for those running Gnome or KDE may be xdg-open. So there would probably need to be a new option for specifying the appropriate command. Personally, I am more inclined to use system for executing commands, and browseURL for opening documents. browseURL even uses xdg-open in my R installation on my Linux machine. - Steve Best, Uwe Ligges Cheers, Brian __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Revision of shell.exec?
2011/9/14 Uwe Ligges lig...@statistik.tu-dortmund.de: On 14.09.2011 12:27, Brian Oney wrote: Hi List, I hope this is correct list to propose function extensions, sorry if not. I am preparing for a (hopefully painless) migration to linux. As far as I am aware of, the function shell.exec only comes with the windows version. I think this is a handy little function and would like to see my scripts work when I migrate. May I propose something (like the following)? open.file - function(file) { if(.Platform$OS.type==windows) {shell.exec(file)} else {system(paste(open ,file))} } Or just a small addition to the shell.exec function and no new named function. Hope the idea isn't received as too stupid. What is open supposed to do on a non-Windows machine? I do not have it on the only Linux installation I looked at now, hence we obviously cannot assume it exists on an arbitrary installation. I think the nearest equivalent for those running Gnome or KDE may be xdg-open. So there would probably need to be a new option for specifying the appropriate command. Personally, I am more inclined to use system for executing commands, and browseURL for opening documents. browseURL even uses xdg-open in my R installation on my Linux machine. - Steve Best, Uwe Ligges Cheers, Brian __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Revision of shell.exec?
On 14 September 2011 at 16:56, Simon Urbanek wrote: | | 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 ...). Not a side-effect, but carefully planned by several parties :) Kurt has this in m4/R.m4 for R's configure: AC_DEFUN([R_PROG_BROWSER], [if test -z ${R_BROWSER}; then AC_PATH_PROGS(R_BROWSER, [firefox mozilla galeon opera xdg-open kfmclient gnome-moz-remote open]) fi and AC_DEFUN([R_PROG_PDFVIEWER], [AC_PATH_PROGS(R_PDFVIEWER, [${R_PDFVIEWER} acroread acroread4 xdg-open evince xpdf gv gnome-gv ggv okular kpdf open gpdf kghostview]) so xdg-open can be use as R_BROWSER and R_PDFVIEWER. That is a 'Good Thing' because xdg-open is itself a wrapper which finds the appropriate _installed_ binary via the desktop resources -- shifting the choice from compile-time to run-time. I then ensure via a Build-Depends on the xdg-utils package ensure that xdg-open is present when R is built (as the Debian / Ubuntu binary). (I also set 'R_BROWSER=xdg-open' in the call to configure which may be redundant.) So we could try to generalize this and, if on Linux, look for xdg-open and call that. 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 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Revision of shell.exec?
Hi List, I hope this is correct list to propose function extensions, sorry if not. I am preparing for a (hopefully painless) migration to linux. As far as I am aware of, the function shell.exec only comes with the windows version. I think this is a handy little function and would like to see my scripts work when I migrate. May I propose something (like the following)? open.file - function(file) { if(.Platform$OS.type==windows) {shell.exec(file)} else {system(paste(open ,file))} } Or just a small addition to the shell.exec function and no new named function. Hope the idea isn't received as too stupid. Cheers, Brian __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Revision of shell.exec?
On 14.09.2011 12:27, Brian Oney wrote: Hi List, I hope this is correct list to propose function extensions, sorry if not. I am preparing for a (hopefully painless) migration to linux. As far as I am aware of, the function shell.exec only comes with the windows version. I think this is a handy little function and would like to see my scripts work when I migrate. May I propose something (like the following)? open.file - function(file) { if(.Platform$OS.type==windows) {shell.exec(file)} else {system(paste(open ,file))} } Or just a small addition to the shell.exec function and no new named function. Hope the idea isn't received as too stupid. What is open supposed to do on a non-Windows machine? I do not have it on the only Linux installation I looked at now, hence we obviously cannot assume it exists on an arbitrary installation. Best, Uwe Ligges Cheers, Brian __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Revision of shell.exec?
Hi Steve, a quick look at browseURL will tell you that indeed system or shell.exec (on a windows platform) is used to open up a URL. The open part of the proposed function was written to work on a Mac. Because Mac is a unix platform, I assumed that the function open would be omnipresent on unix platforms, my mistake. Well I guess, we know how to make to work on a mac. I will make the transition to Linux and get back to this in a while, ok? Cheers, Brian On 9/14/2011 2:50 PM, Stephen Weston wrote: 2011/9/14 Uwe Liggeslig...@statistik.tu-dortmund.de: On 14.09.2011 12:27, Brian Oney wrote: Hi List, I hope this is correct list to propose function extensions, sorry if not. I am preparing for a (hopefully painless) migration to linux. As far as I am aware of, the function shell.exec only comes with the windows version. I think this is a handy little function and would like to see my scripts work when I migrate. May I propose something (like the following)? open.file- function(file) { if(.Platform$OS.type==windows) {shell.exec(file)} else {system(paste(open ,file))} } Or just a small addition to the shell.exec function and no new named function. Hope the idea isn't received as too stupid. What is open supposed to do on a non-Windows machine? I do not have it on the only Linux installation I looked at now, hence we obviously cannot assume it exists on an arbitrary installation. I think the nearest equivalent for those running Gnome or KDE may be xdg-open. So there would probably need to be a new option for specifying the appropriate command. Personally, I am more inclined to use system for executing commands, and browseURL for opening documents. browseURL even uses xdg-open in my R installation on my Linux machine. - Steve Best, Uwe Ligges Cheers, Brian __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Revision of shell.exec?
On Sep 14, 2011, at 11:08 AM, Brian Oney wrote: Hi Steve, a quick look at browseURL will tell you that indeed system or shell.exec (on a windows platform) is used to open up a URL. The open part of the proposed function was written to work on a Mac. Because Mac is a unix platform, I assumed that the function open would be omnipresent on unix platforms, my mistake. Well, the problem is that open is unfortunately mapped to openvt on Linux systems which is a quite obscure anachronism. But since Linux is Linux there is no standard way to open a file, so it doesn't really matter ;) -- xdg-utils come closest to what one may call standard but on many systems they are not installed by default (in fact on none of the Linux machines I have around). For URLs R does the hard work to try to figure out what to do with them (it also does the same for PDFs), but you may end up opening things in a browser although that's not what you had in mind. Well I guess, we know how to make to work on a mac. Yes, open works very well on Macs and is extremely useful (I use it all the time - among other things you can use it with directories to browse them...) - it is still beyond me why other unices don't bother ... Cheers, Simon I will make the transition to Linux and get back to this in a while, ok? Cheers, Brian On 9/14/2011 2:50 PM, Stephen Weston wrote: 2011/9/14 Uwe Liggeslig...@statistik.tu-dortmund.de: On 14.09.2011 12:27, Brian Oney wrote: Hi List, I hope this is correct list to propose function extensions, sorry if not. I am preparing for a (hopefully painless) migration to linux. As far as I am aware of, the function shell.exec only comes with the windows version. I think this is a handy little function and would like to see my scripts work when I migrate. May I propose something (like the following)? open.file- function(file) { if(.Platform$OS.type==windows) {shell.exec(file)} else {system(paste(open ,file))} } Or just a small addition to the shell.exec function and no new named function. Hope the idea isn't received as too stupid. What is open supposed to do on a non-Windows machine? I do not have it on the only Linux installation I looked at now, hence we obviously cannot assume it exists on an arbitrary installation. I think the nearest equivalent for those running Gnome or KDE may be xdg-open. So there would probably need to be a new option for specifying the appropriate command. Personally, I am more inclined to use system for executing commands, and browseURL for opening documents. browseURL even uses xdg-open in my R installation on my Linux machine. - Steve Best, Uwe Ligges Cheers, Brian __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Revision of shell.exec?
On Wed, Sep 14, 2011 at 8:35 AM, Simon Urbanek simon.urba...@r-project.org wrote: On Sep 14, 2011, at 11:08 AM, Brian Oney wrote: Hi Steve, a quick look at browseURL will tell you that indeed system or shell.exec (on a windows platform) is used to open up a URL. The open part of the proposed function was written to work on a Mac. Because Mac is a unix platform, I assumed that the function open would be omnipresent on unix platforms, my mistake. Well, the problem is that open is unfortunately mapped to openvt on Linux systems which is a quite obscure anachronism. But since Linux is Linux there is no standard way to open a file, so it doesn't really matter ;) -- xdg-utils come closest to what one may call standard but on many systems they are not installed by default (in fact on none of the Linux machines I have around). For URLs R does the hard work to try to figure out what to do with them (it also does the same for PDFs), but you may end up opening things in a browser although that's not what you had in mind. Well I guess, we know how to make to work on a mac. Yes, open works very well on Macs and is extremely useful (I use it all the time - among other things you can use it with directories to browse them...) - it is still beyond me why other unices don't bother ... Apple probably patented it. /Henrik Cheers, Simon I will make the transition to Linux and get back to this in a while, ok? Cheers, Brian On 9/14/2011 2:50 PM, Stephen Weston wrote: 2011/9/14 Uwe Liggeslig...@statistik.tu-dortmund.de: On 14.09.2011 12:27, Brian Oney wrote: Hi List, I hope this is correct list to propose function extensions, sorry if not. I am preparing for a (hopefully painless) migration to linux. As far as I am aware of, the function shell.exec only comes with the windows version. I think this is a handy little function and would like to see my scripts work when I migrate. May I propose something (like the following)? open.file- function(file) { if(.Platform$OS.type==windows) {shell.exec(file)} else {system(paste(open ,file))} } Or just a small addition to the shell.exec function and no new named function. Hope the idea isn't received as too stupid. What is open supposed to do on a non-Windows machine? I do not have it on the only Linux installation I looked at now, hence we obviously cannot assume it exists on an arbitrary installation. I think the nearest equivalent for those running Gnome or KDE may be xdg-open. So there would probably need to be a new option for specifying the appropriate command. Personally, I am more inclined to use system for executing commands, and browseURL for opening documents. browseURL even uses xdg-open in my R installation on my Linux machine. - Steve Best, Uwe Ligges Cheers, Brian __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Revision of shell.exec?
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) On windows, (an advantage...) somebody wrote a little program open.exe that comes stock with an R-installation, which somehow accesses the file system to find the default program to for a certain file type. I am guessing this little beauty is the engine of shell.exec. (An honest) cheers, Brian On 9/14/2011 7:49 PM, Simon Urbanek wrote: On Sep 14, 2011, at 1:10 PM, Henrik Bengtsson wrote: On Wed, Sep 14, 2011 at 8:35 AM, Simon Urbanek simon.urba...@r-project.org wrote: On Sep 14, 2011, at 11:08 AM, Brian Oney wrote: Hi Steve, a quick look at browseURL will tell you that indeed system or shell.exec (on a windows platform) is used to open up a URL. The open part of the proposed function was written to work on a Mac. Because Mac is a unix platform, I assumed that the function open would be omnipresent on unix platforms, my mistake. Well, the problem is that open is unfortunately mapped to openvt on Linux systems which is a quite obscure anachronism. But since Linux is Linux there is no standard way to open a file, so it doesn't really matter ;) -- xdg-utils come closest to what one may call standard but on many systems they are not installed by default (in fact on none of the Linux machines I have around). For URLs R does the hard work to try to figure out what to do with them (it also does the same for PDFs), but you may end up opening things in a browser although that's not what you had in mind. Well I guess, we know how to make to work on a mac. Yes, open works very well on Macs and is extremely useful (I use it all the time - among other things you can use it with directories to browse them...) - it is still beyond me why other unices don't bother ... Apple probably patented it. I'm pretty sure it's at least as old as NeXT so that's way before the abuse of software patents ;) - but who knows ... Cheers, S /Henrik Cheers, Simon I will make the transition to Linux and get back to this in a while, ok? Cheers, Brian On 9/14/2011 2:50 PM, Stephen Weston wrote: 2011/9/14 Uwe Liggeslig...@statistik.tu-dortmund.de: On 14.09.2011 12:27, Brian Oney wrote: Hi List, I hope this is correct list to propose function extensions, sorry if not. I am preparing for a (hopefully painless) migration to linux. As far as I am aware of, the function shell.exec only comes with the windows version. I think this is a handy little function and would like to see my scripts work when I migrate. May I propose something (like the following)? open.file- function(file) { if(.Platform$OS.type==windows) {shell.exec(file)} else {system(paste(open ,file))} } Or just a small addition to the shell.exec function and no new named function. Hope the idea isn't received as too stupid. What is open supposed to do on a non-Windows machine? I do not have it on the only Linux installation I looked at now, hence we obviously cannot assume it exists on an arbitrary installation. I think the nearest equivalent for those running Gnome or KDE may be xdg-open. So there would probably need to be a new option for specifying the appropriate command. Personally, I am more inclined to use system for executing commands, and browseURL for opening documents. browseURL even uses xdg-open in my R installation on my Linux machine. - Steve Best, Uwe Ligges Cheers, Brian __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Revision of shell.exec?
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 ... Cheers, Simon On windows, (an advantage...) somebody wrote a little program open.exe that comes stock with an R-installation, which somehow accesses the file system to find the default program to for a certain file type. I am guessing this little beauty is the engine of shell.exec. (An honest) cheers, Brian On 9/14/2011 7:49 PM, Simon Urbanek wrote: On Sep 14, 2011, at 1:10 PM, Henrik Bengtsson wrote: On Wed, Sep 14, 2011 at 8:35 AM, Simon Urbanek simon.urba...@r-project.org wrote: On Sep 14, 2011, at 11:08 AM, Brian Oney wrote: Hi Steve, a quick look at browseURL will tell you that indeed system or shell.exec (on a windows platform) is used to open up a URL. The open part of the proposed function was written to work on a Mac. Because Mac is a unix platform, I assumed that the function open would be omnipresent on unix platforms, my mistake. Well, the problem is that open is unfortunately mapped to openvt on Linux systems which is a quite obscure anachronism. But since Linux is Linux there is no standard way to open a file, so it doesn't really matter ;) -- xdg-utils come closest to what one may call standard but on many systems they are not installed by default (in fact on none of the Linux machines I have around). For URLs R does the hard work to try to figure out what to do with them (it also does the same for PDFs), but you may end up opening things in a browser although that's not what you had in mind. Well I guess, we know how to make to work on a mac. Yes, open works very well on Macs and is extremely useful (I use it all the time - among other things you can use it with directories to browse them...) - it is still beyond me why other unices don't bother ... Apple probably patented it. I'm pretty sure it's at least as old as NeXT so that's way before the abuse of software patents ;) - but who knows ... Cheers, S /Henrik Cheers, Simon I will make the transition to Linux and get back to this in a while, ok? Cheers, Brian On 9/14/2011 2:50 PM, Stephen Weston wrote: 2011/9/14 Uwe Liggeslig...@statistik.tu-dortmund.de: On 14.09.2011 12:27, Brian Oney wrote: Hi List, I hope this is correct list to propose function extensions, sorry if not. I am preparing for a (hopefully painless) migration to linux. As far as I am aware of, the function shell.exec only comes with the windows version. I think this is a handy little function and would like to see my scripts work when I migrate. May I propose something (like the following)? open.file- function(file) { if(.Platform$OS.type==windows) {shell.exec(file)} else {system(paste(open ,file))} } Or just a small addition to the shell.exec function and no new named function. Hope the idea isn't received as too stupid. What is open supposed to do on a non-Windows machine? I do not have it on the only Linux installation I looked at now, hence we obviously cannot assume it exists on an arbitrary installation. I think the nearest equivalent for those running Gnome or KDE may be xdg-open. So there would probably need to be a new option for specifying the appropriate command. Personally, I am more inclined to use system for executing commands, and browseURL for opening documents. browseURL even uses xdg-open in my R installation on my Linux machine. - Steve Best, Uwe Ligges Cheers, Brian __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Revision of shell.exec?
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... 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 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Revision of shell.exec?
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 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel