Hello useRs! I have a small package and I need internet access for examples. Of course it works fine when I have internet access, but not otherwise. I remember I saw a way to test availability of internet access, but I can not find it now in archives. Can anyone here help me? Thanks! -- Lep pozdrav / With regards, Gregor Gorjanc ---------------------------------------------------------------------- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc <at> bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europe fax: +386 (0)1 72 17 888 ---------------------------------------------------------------------- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C.
The function download.file (invisibly) returns a non-negative integer if it fails, so I suppose you could use this as a test. On 11/09/06, Gregor Gorjanc <gregor.gorjanc at bfro.uni-lj.si> wrote:> Hello useRs! > > I have a small package and I need internet access for examples. Of > course it works fine when I have internet access, but not otherwise. I > remember I saw a way to test availability of internet access, but I can > not find it now in archives. Can anyone here help me? > > Thanks! > > -- > Lep pozdrav / With regards, > Gregor Gorjanc > > ---------------------------------------------------------------------- > University of Ljubljana PhD student > Biotechnical Faculty > Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan > Groblje 3 mail: gregor.gorjanc <at> bfro.uni-lj.si > > SI-1230 Domzale tel: +386 (0)1 72 17 861 > Slovenia, Europe fax: +386 (0)1 72 17 888 > > ---------------------------------------------------------------------- > "One must learn by doing the thing; for though you think you know it, > you have no certainty until you try." Sophocles ~ 450 B.C. > > ______________________________________________ > 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. >-- ================================David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP
I means non-zero, not non-negative. On 11/09/06, David Barron <mothsailor at googlemail.com> wrote:> The function download.file (invisibly) returns a non-negative integer > if it fails, so I suppose you could use this as a test. > > On 11/09/06, Gregor Gorjanc <gregor.gorjanc at bfro.uni-lj.si> wrote: > > Hello useRs! > > > > I have a small package and I need internet access for examples. Of > > course it works fine when I have internet access, but not otherwise. I > > remember I saw a way to test availability of internet access, but I can > > not find it now in archives. Can anyone here help me? > > > > Thanks! > > > > -- > > Lep pozdrav / With regards, > > Gregor Gorjanc > > > > ---------------------------------------------------------------------- > > University of Ljubljana PhD student > > Biotechnical Faculty > > Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan > > Groblje 3 mail: gregor.gorjanc <at> bfro.uni-lj.si > > > > SI-1230 Domzale tel: +386 (0)1 72 17 861 > > Slovenia, Europe fax: +386 (0)1 72 17 888 > > > > ---------------------------------------------------------------------- > > "One must learn by doing the thing; for though you think you know it, > > you have no certainty until you try." Sophocles ~ 450 B.C. > > > > ______________________________________________ > > 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. > > > > > -- > ================================> David Barron > Said Business School > University of Oxford > Park End Street > Oxford OX1 1HP >-- ================================David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP
David Barron wrote:> I means non-zero, not non-negative. >... Thanks. download.file() is fine! -- Lep pozdrav / With regards, Gregor Gorjanc ---------------------------------------------------------------------- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc <at> bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europe fax: +386 (0)1 72 17 888 ---------------------------------------------------------------------- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C.
Gregor Gorjanc wrote:> Hello useRs! > > I have a small package and I need internet access for examples. Of > course it works fine when I have internet access, but not otherwise. I > remember I saw a way to test availability of internet access, but I can > not find it now in archives. Can anyone here help me? > > David Barron wrote: >> I means non-zero, not non-negative. >> > ... > > Thanks. download.file() is fine! >Thinking a bit more, download.file() is not really general as I need to specify an url and it might happen that I have internet connection, but server that provides url is down. I am to picky on this? -- Lep pozdrav / With regards, Gregor Gorjanc ---------------------------------------------------------------------- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc <at> bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europe fax: +386 (0)1 72 17 888 ---------------------------------------------------------------------- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C.
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
Prof Brian Ripley wrote:> 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.) > >... Thank you for additional pointer. I did not look windows help page as I do not have windows at disposal all the time, but You are right - I should have looked into the sources. I found out that there is no such function i.e. nsl() under windows. If I summarize the thread there is (currently) no way to test for internet presence with a general approach. -- Lep pozdrav / With regards, Gregor Gorjanc ---------------------------------------------------------------------- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc <at> bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europe fax: +386 (0)1 72 17 888 ---------------------------------------------------------------------- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C.