[R] Test internet presence
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Sep 12 17:52:56 CEST 2006
On Mon, 11 Sep 2006, Gregor Gorjanc wrote:
> Prof Brian Ripley <ripley <at> stats.ox.ac.uk> writes:
> ...
> > Check out tests/internet.R. nsl() checks if you can resolve host names,
> > which has worked well enough there.
>
> Thank you prof. Ripley for this pointer. I am posting here the relevant part if
> someone does not look at SVN. I would just like to ask why is .Platform$OS.type
> == "unix" added to the test? Is nsl() available only on unix like platforms or
> ... I did not found any specifics in its help page.
Did you look at the help page on Windows? Looking at the help page on
Unix only tells you about Unix.
Hint: the help page is src/library/utils/man/unix/nsl.Rd
(In my country, PhD students are supposed to be able to find things
like that out for themselves.)
>
> if(!capabilities()["http/ftp"]) {
> warning("no internet capabilities")
> q()
> }
>
> if(.Platform$OS.type == "unix" &&
> is.null(nsl("cran.r-project.org"))) q()
>
> Does it make any sense to write a function that would use these two tests.
>
> isNetAvailable <- function()
> {
> ifelse(!capabilities()["http/ftp"] &&
> ## .Platform$OS.type == "unix" && ## ???
> is.null(nsl("cran.r-project.org")),
> FALSE,
> TRUE)
> }
>
> Regards, Gregor
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Brian D. Ripley, ripley at 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, UK Fax: +44 1865 272595
More information about the R-help
mailing list