| View previous topic :: View next topic |
| Author |
Message |
leandro Voice
Joined: 02 Jun 2007 Posts: 13
|
Posted: Fri Jun 08, 2007 11:02 am Post subject: Egghttp, sockets in sockets.. |
|
|
I am creating an online database, So I need to connect to a webpage, read the first line, open another connection, fill in some data, and then go to the second, and so on.
Now, I have this:
| Code: | et url "http://localhost/akicks/todo.php"
set trigger "!test"
if {![info exists egghttp(version)]} {
putlog "egghttp.tcl was NOT successfully loaded."
putlog "http-akicks.tcl has not been loaded as a result."
} else {
proc your_callbackproc {sock} {
global url
set headers [egghttp:headers $sock]
set body [egghttp:data $sock]
foreach line [split $body \n] {
regsub -all -nocase {<br>} $line "" line
regsub -all -nocase {<b>} $line "" line
regsub -all -nocase {</b>} $line "" line
set id [lindex $line 0]
set secondline [string trimleft $line $id]
set com [lindex $secondline 0]
set newurl "http://localhost/akicks/mark.php?id=$id&com=$com&pass=12ledro"
set sockset [egghttp:geturl $newurl akick_proc]
return 1
}
proc akick_proc {sock} {
set headersset [egghttp:headers $sockset]
set bodyset [egghttp:data $sockset]
foreach line [split $body \n]
if {$bodyset == "Ok"} {
putlog "success"
}
}
}
bind dcc o|o $trigger our:dcctrigger
bind pub o|o $trigger our:pubtrigger
proc our:dcctrigger {hand idx text} {
global url
set sock [egghttp:geturl $url your_callbackproc]
return 1
}
proc our:pubtrigger {nick host hand chan arg} {
global url
set sock [egghttp:geturl $url your_callbackproc]
return 1
}
putlog "http-akicks.tcl has been successfully loaded."
} |
But this only seems to work for the first line. Any suggestions? |
|
| Back to top |
|
 |
leandro Voice
Joined: 02 Jun 2007 Posts: 13
|
Posted: Sun Jun 10, 2007 7:01 am Post subject: |
|
|
| Anyone? Pleaseee? |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Sun Jun 10, 2007 8:50 pm Post subject: |
|
|
| Switch to the http module that comes with tcl and I might be able to help. |
|
| Back to top |
|
 |
leandro Voice
Joined: 02 Jun 2007 Posts: 13
|
Posted: Mon Jun 11, 2007 10:36 am Post subject: |
|
|
| Im afraid I dont know about any HTTP module... Do you have a tutorial somewhere? |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Mon Jun 11, 2007 4:01 pm Post subject: |
|
|
| The http package is well documented in the tcl man pages.. There's also a thousand example scripts here and in the archives (all of my webscripts use the http package, a few use the socket code, none use egghttp.tcl) |
|
| Back to top |
|
 |
|