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.

TCL to read php file

Old posts that have not been replied to for several years.
Locked
d
drl

TCL to read php file

Post by drl »

I am writing a script for an IRC channel for a radio station which will basically look at a php file once an hour which will contain which show is on air.

Thing is... I am new to TCL and not sure how to a) get it to perform this action once an hour or b) actually get it to read a php file from a website.

Any help will be greatly recived.

Thanks,

David
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

a) use the 'time' bind or 'timer' command (see tcl-commands.doc)

b) try the http.tcl package (search for it)
d
drl

Post by drl »

Code: Select all

bind time - "00 * * * *"   autoupdate

proc autoupdate {set while get putserv} {

set file [open "|lynx -source http://website.com/file.txt" r] 
while {![eof $file]} { 
gets $file html 
if {$html == {}} {continue} 
set html [string trimleft $html "<h1>"] 
set html [string trimright $html "</h1>"] 

putserv "TOPIC $chan :Welcome To The #channel - 4Currently on air:7 $html"
#putserv "NOTICE $chan :$html is now on air. 


 }
}
I can get it to read from the file fine - but tell me someone, why doesnt run the proc on the hour properly?

Thanks,

DL
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

I don't know where you got your arguments, set while get putserv, but you can't just make these things up hehe.

Look in tcl-commands.doc for the arguments used in a time bind.
d
drl

Post by drl »

to be truthfull I've never done tcl before - and I don't really need to learn it other than to do this one thing. I dont understand all these arguments, so please could someone tell me what arguments to put?

PLEEEEEASE!

Thanks,

DRL
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Did you even look? It's pretty self explanatory.

(37) TIME (stackable)
bind time <flags> <mask> <proc>
proc-name <minute> <hour> <day> <month> <year>
d
drl

Post by drl »

I did look at something but I never saw that.

So should my code now read this:

Code: Select all

bind time - "00 * * * *"   autoupdate 

proc autoupdate {00 * * * *} { 

set file [open "|lynx -source http://website.com/file.txt" r] 
while {![eof $file]} { 
gets $file html 
if {$html == {}} {continue} 
set html [string trimleft $html "<h1>"] 
set html [string trimright $html "</h1>"] 

putserv "TOPIC $chan :Welcome To The #channel - 4Currently on air:7 $html" 
#putserv "NOTICE $chan :$html is now on air. 


} 
}
I do apologise for my stupidity but this is my first ever use of tcl.

DL
d
drl

Post by drl »

Thanks for your help - I have it working brilliantly now
Locked