egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

http package and FreeBSD

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Fri Mar 20, 2009 7:24 am    Post subject: http package and FreeBSD Reply with quote

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:

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:

package require http


Are there known issues with FreeBSD/http?
_________________
I must have had nothing to do
Back to top
View user's profile Send private message
scotteh
Halfop


Joined: 29 Jan 2006
Posts: 50

PostPosted: Fri Mar 20, 2009 12:38 pm    Post subject: Reply with quote

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

Try using:
Code:
package require http 2
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Fri Mar 20, 2009 1:18 pm    Post subject: Reply with quote

May I suggest a different approach to that code?

Code:
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, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Fri Mar 20, 2009 1:18 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
dj-zath
Op


Joined: 15 Nov 2008
Posts: 134

PostPosted: Mon Mar 23, 2009 11:51 am    Post subject: Reply with quote

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... Smile

DjZ
Smile Smile
Back to top
View user's profile Send private message Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Mon Mar 23, 2009 12:20 pm    Post subject: Reply with quote

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, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Tue Mar 24, 2009 6:05 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Mar 24, 2009 2:30 pm    Post subject: Reply with quote

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:
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, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber