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.

http package and FreeBSD

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

http package and FreeBSD

Post by arfer »

I wrote a script using http package that works fine with Eggdrop on what I suppose could be called normal linux distros. Several examples would have me conclude that with Eggdrop on FreeBSD it does not function.

The act of trying to grab the url is caught and outputs an error, typically by the following statement :-

Code: Select all

if {![catch {set data [::http::geturl $url -timeout 15000]}]} {
    pDealWithData
} else {putserv "PRIVMSG $chan :error in grabbing url"}
Just to prove http is present, it does not fail at the statement :-

Code: Select all

package require http
Are there known issues with FreeBSD/http?
I must have had nothing to do
s
scotteh
Halfop
Posts: 50
Joined: Sun Jan 29, 2006 12:43 am

Post by scotteh »

What version of the package is getting loaded? Could be loading 1.0.

Try using:

Code: Select all

package require http 2
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

May I suggest a different approach to that code?

Code: Select all

if {![catch {::http::geturl $url -timeout 15000} data]} {
 pDealWithData
} else {
 putserv "PRIVMSG $chan :Error in grabbing url: $data"
}
Doing it this way, leaves us with the output from ::http::geturl in data if the request is successful, and the error message in data if we're not. Also, saves us from cluttering the code with unneeded nested function calls.
NML_375
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

OK nml375, point taken.

For the moment though I'm looking for the FreeBSD issue, if there is one.

scotteh, norm is 2.5.x but on one of the FreeBSD installations I noticed it was 2.7.x
I must have had nothing to do
d
dj-zath
Op
Posts: 134
Joined: Sat Nov 15, 2008 6:49 am
Contact:

Post by dj-zath »

I'm also using FreeBSD.. and I, too, am having problems with the http package.. actually opening/closing connections in general..

oh BOY!

NML: I figured out whats causing the INDEFINATE freeze in eggdrop.. the freaking handshaking! I currently took your code examples and , "piece-by-piece".. I have tested each section.. and found that if its currently connected, then disconnects.. it NEVER finishes the closure!

oops, sorry.. this is meant for the other thread... :-)

DjZ
:) :)
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Arfer:
Just saying that the error message you get from the http:geturl would be very helpful tracking down where things go wrong.. be it tcl, the http-package, freebsd, or just random errors. At least it gives a hint where to look.
NML_375
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

OK, you are correct, I'll mod the script as you suggested and try to find the last person to report an error. I don't have a FreeBSD shell.
I must have had nothing to do
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Also, if you'd like even further debugging info, make use of the ::errorInfo and ::errorCode variables.

A quick sample that logs additional data if debug is set:

Code: Select all

if {![catch {::http::geturl $url -timeout 15000} data]} {
  pDealWithData
} else {
  putserv "PRIVMSG $chan :Error in grabbing url: $data"
  if {[info exists ::debug]} {
    putlog "Error while reading $url: $data"
    putlog "  error code: $::errorCode"
    putlog "  stack trace: $::errorInfo"
  }
}
NML_375
Post Reply