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.
Ignore errors if no internet connection
-
serendipity
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
-
admin
- Site Admin
- Posts: 66350
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Ignore errors if no internet connection
I added something experimentally. Next version add a 4th parameter and set it to 1:
Now readurl() should return silently when you are offline and $ReadURL will be "" (empty).
Code: Select all
$ReadURL = readurl("http://www.xyplorer.com/xyfc/viewtopic.php?t=4&start=0&sd=d", , , 1); FAQ | XY News RSS | XY X
-
serendipity
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Re: Ignore errors if no internet connection
Thanks, I'll try that in the next version.admin wrote:I added something experimentally. Next version add a 4th parameter and set it to 1:
Now readurl() should return silently when you are offline and $ReadURL will be "" (empty).Code: Select all
$ReadURL = readurl("http://www.xyplorer.com/xyfc/viewtopic.php?t=4&start=0&sd=d", , , 1);
-
serendipity
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Re: Ignore errors if no internet connection
Thanks! it works now. I'll update the script.
-
admin
- Site Admin
- Posts: 66350
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Ignore errors if no internet connection
Actually I wonder if this should be the hard-coded default functionality anyway! What do you think?serendipity wrote:Thanks! it works now. I'll update the script.
FAQ | XY News RSS | XY X
-
PeterH
- Posts: 2827
- Joined: 21 Nov 2005 20:39
- Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%
Re: Ignore errors if no internet connection
I still didn't understand, what happens till now...admin wrote:Actually I wonder if this should be the hard-coded default functionality anyway! What do you think?serendipity wrote:Thanks! it works now. I'll update the script.
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
-
TheQwerty
- Posts: 4373
- Joined: 03 Aug 2007 22:30
Re: Ignore errors if no internet connection
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 "".
That said, I don't actually need such functionality so I'm not opposed to just making it return "".
-
admin
- Site Admin
- Posts: 66350
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Ignore errors if no internet connection
Yes, agreed. I will leave at the current state for the time being. Some fine day I will add optional output arguments...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.
FAQ | XY News RSS | XY X
XYplorer Beta Club