Page 1 of 1
Ignore errors if no internet connection
Posted: 10 Oct 2010 16:57
by serendipity
I am trying a script which will check for XY updates on startup. It works nicely but have not posted it yet, because if I donot have internet connection then it throws an error on XY startup which is kind of ugly.
Is there a way to check that I have internet connection so that I an include that in my script? Or altenatively, if command readurl is throwing an error then someway of ignoring this?
Thanks.
PS: maybe I'll just post this script anyway.
Re: Ignore errors if no internet connection
Posted: 10 Oct 2010 20:38
by admin
I added something experimentally. Next version add a 4th parameter and set it to 1:
Code: Select all
$ReadURL = readurl("http://www.xyplorer.com/xyfc/viewtopic.php?t=4&start=0&sd=d", , , 1);
Now readurl() should return silently when you are offline and $ReadURL will be "" (empty).
Re: Ignore errors if no internet connection
Posted: 10 Oct 2010 21:40
by serendipity
admin wrote:I added something experimentally. Next version add a 4th parameter and set it to 1:
Code: Select all
$ReadURL = readurl("http://www.xyplorer.com/xyfc/viewtopic.php?t=4&start=0&sd=d", , , 1);
Now readurl() should return silently when you are offline and $ReadURL will be "" (empty).
Thanks, I'll try that in the next version.
Re: Ignore errors if no internet connection
Posted: 12 Oct 2010 01:18
by serendipity
Thanks! it works now. I'll update the script.
Re: Ignore errors if no internet connection
Posted: 13 Oct 2010 09:38
by admin
serendipity wrote:Thanks! it works now. I'll update the script.
Actually I wonder if this should be the hard-coded default functionality anyway! What do you think?
Re: Ignore errors if no internet connection
Posted: 13 Oct 2010 11:03
by PeterH
admin wrote:serendipity wrote:Thanks! it works now. I'll update the script.
Actually I wonder if this should be the hard-coded default functionality anyway! What do you think?
I still didn't understand, what happens till now...
But if I understand it right, it doesn't seem bad, if readurl() returns "" when no connection is possible, instead of showing an error.
(Though I didn't use it

)
Re: Ignore errors if no internet connection
Posted: 13 Oct 2010 12:58
by TheQwerty
Technically, it should be possible for the script to distinguish between not being connected and an empty return from the URL. It would really be best if we could somehow get the resulting
HTTP status as well.
That said, I don't actually need such functionality so I'm not opposed to just making it return "".

Re: Ignore errors if no internet connection
Posted: 13 Oct 2010 13:28
by admin
TheQwerty wrote:Technically, it should be possible for the script to distinguish between not being connected and an empty return from the URL. It would really be best if we could somehow get the resulting
HTTP status as well.
Yes, agreed. I will leave at the current state for the time being. Some fine day I will add optional output arguments...