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 

host unavaible on webpage error

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


Joined: 24 Jul 2003
Posts: 64

PostPosted: Sun Nov 04, 2007 10:33 pm    Post subject: host unavaible on webpage error Reply with quote

I wrote an eggy script for our shoutcast radio channel. Part of what this script does is check the status web page every time someone joins the channel to determine if someone is streaming or not.(Bloody dj's don't know how to follow instructions). There are times when the bot can't reach the host(shoutcast is on the same server/shell), which probably occurs because nobody is streaming and shoutcast server is just not responding(don't know if this is the case).

The problem I'm having is that when I receive that error:
Quote:
[21:13] Tcl error [ListenersCommand]: couldn't open socket: host is unreachable

That the rest of the commands do not run... And it seems, that after it receives that error that even if someone is streaming... The bot can not connect to the host.

So, my question is 2 fold.
1). How do I check for errors on the read to the web page and make the rest of the code in the paragraph work.
2). Why doesn't it connect to the web page after I know that it is responding. And yes, it will connect ok to the web page most of the time.

Code:
 foreach lcl_URL_Port_type $gbl_ary_check_web_pages      {
                set lcl_URL_fields [split $lcl_URL_Port_type ":"]
                set lcl_URL  [lindex $lcl_URL_fields 0]
                set lcl_Port [lindex [split [lindex $lcl_URL_fields 1] "~"] 0]
                set lcl_StreamWebPageScoket [socket $lcl_URL $lcl_Port]
                # I have no idea what this [censored] does. Not a clue
                puts -nonewline $lcl_StreamWebPageScoket "GET /7.html HTTP/1.1\nAccept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-sh
ockwave-flash, */*\nAccept-Language: en-us\nAccept-Encoding: gzip, deflate\nUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; T312461; (R1 1.3); .NE
T CLR 1.0.3705; .NET CLR 1.1.4322)\nHost: www.awesomechat.net\nConnection: Keep-Alive\n\n"

                flush $lcl_StreamWebPageScoket
                while {![eof $lcl_StreamWebPageScoket]} {set line [gets $lcl_StreamWebPageScoket]
                        set lcl_crap "body"
                        set lcl_Start 0
                        set lcl_End   0
                        if { [string match *$lcl_crap* $line] } {


Please note, that this is a common procedure that is called from a number of other procedures. And that two web pages are pulled... 2 different ports due to 2 instances of shoutcast running.

droolin[/code]
Back to top
View user's profile Send private message Visit poster's website
droolin
Halfop


Joined: 24 Jul 2003
Posts: 64

PostPosted: Sun Nov 04, 2007 10:36 pm    Post subject: actualy, now that I posted that. Reply with quote

I see something wrong with it...

But that still doesn't answer one of my questions... I should always check to make sure that a command executes properly such as accessing a web page, accessing a file.

How do you go about doing that so that the rest of the procedure still executes and you do not receive tcl errors?

droolin
Back to top
View user's profile Send private message Visit poster's website
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Mon Nov 05, 2007 12:50 am    Post subject: Reply with quote

# I have no idea what this [censored] does. Not a clue


Uhm... Thats one way of grabbing webpages. Using the http package is prefered nowdays. You can use catch[] to handle error conditions, for example:

Code:

catch {set page [::http::geturl $movieurl -timeout $::movietimeout]} error
   if {[string match -nocase "*couldn't open socket*" $error]} {
      puthelp "PRIVMSG $chan :Error: couldn't connect to filmspot.com..Try again later."
      return
   }
   if { [::http::status $page] == "timeout" } {
      puthelp "PRIVMSG $chan :Error: Connection to filmspot.com timed out..Try again later."
      return
   }
   set html [::http::data $page]
   ::http::cleanup $page
   if {[regexp $regexm $html match moviedata]} {

Thats an example of retrieving web data and handling the error conditions, using the http package.
Back to top
View user's profile Send private message
droolin
Halfop


Joined: 24 Jul 2003
Posts: 64

PostPosted: Mon Nov 05, 2007 7:55 am    Post subject: Thank you Reply with quote

Sorry about not removing that comment before I posted...

But I do appriceate the information both on the catch and on the http package. Especially the examples.

droolin
Back to top
View user's profile Send private message Visit poster's website
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