This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Lynx problem

Old posts that have not been replied to for several years.
Locked
c
cerberus_gr
Halfop
Posts: 97
Joined: Fri Feb 07, 2003 8:57 am
Location: 127.0.0.1

Lynx problem

Post by cerberus_gr »

Hello,

i have this command in my code: exec $lynx -preparsed -dump $radio(host)

if $radio(host) is down, lynx returns an error:
[18:26] Tcl error [radio:dataget]:
Looking up www.xxxx.com
Unable to locate remote host www.xxxx.com.
Alert!: Unable to connect to remote host.
lynx: Can't access startfile http://www.xxxx.com

how could I check if the host is up or not, so if it's down this procedure do not return a error?

thx
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Use the likes of the Tcl HTTP package.

You have full control over how errors return then.
c
cerberus_gr
Halfop
Posts: 97
Joined: Fri Feb 07, 2003 8:57 am
Location: 127.0.0.1

Post by cerberus_gr »

:(
I don't know this package. could you help me a little more?

My code is:

Code: Select all

proc radio:dataget { hand idx text } {
    global lynx radio
    set rfs "[open $radio(file) w]"
    puts $rfs [exec $lynx -preparsed -dump http://www.xxxx.com:$radio(port)]
    close $rfs
    return 0
}
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

If all you want to do is get rid of the tcl error, add a catch statement:

Code: Select all

proc radio:dataget { hand idx text } {
    global lynx radio
    set rfs "[open $radio(file) w]"
    if {[catch {exec $lynx -preparsed -dump http://www.xxxx.com:$radio(port)} result]} {
        putlog "error"
    } else {
        puts $rfs $result
    }
    close $rfs
    return 0
}
Maybe instead of putlog "error", you want to put a default message into that file, indicating that the site could not be contacted.
Locked