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 

URL logging

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


Joined: 12 Aug 2007
Posts: 13

PostPosted: Fri Oct 26, 2007 8:25 pm    Post subject: URL logging Reply with quote

Hello, I have modified the URL title script to log URL's posted to a chan and output it to a html file. It works sometimes, it will log a few links, but then for some strange reason it will overwrite the whole file with a blank file, and start over.. It usually will log 3-4 urls before restarting.. Here is the part I modified (the rest of the script seems to work well). I each url posted to be inserted into the top of the file
Quote:

if {[string match "*://*" $word]} {
set ulf [open /home/peakoil/public_html/urls.html r]
set ulogdata [read -nonewline $ulf]
close $ulf
set ulines [split $ulogdata "\n"]
set ulf [open /home/peakoil/public_html/urls.html w]
set urlline "<a href=\"$word\">$urtitle</a><br>"
set ulines [linsert $ulines 0 $urlline]
puts $ulf [join $ulines "\n"]
close $ulf
}


Thanks for your help!
_________________
irc://irc.efnet.net/peakoil
Back to top
View user's profile Send private message
rosc2112
Revered One


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

PostPosted: Sat Oct 27, 2007 4:21 am    Post subject: Reply with quote

If you're going to modify other peoples scripts, you best learn how to debug them as well.. Try adding putcmdlog lines in so you can see what's going on.
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Sat Oct 27, 2007 7:30 am    Post subject: Reply with quote

Why don't you use a regexp to extract the URL?

And opening twice the same file is quite unoptimised.

You can open the file in read/write mode and get each line one by one. If the line matches your current URL, exit the loop (and do nothing). When arriving at the end of the file (so, you didn't see the url), just append it to your file.
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
pitbull
Voice


Joined: 12 Aug 2007
Posts: 13

PostPosted: Sat Oct 27, 2007 8:02 am    Post subject: Reply with quote

ok let me clear some things up. The code you saw is mine, I added it into a script that grabs the url title of a url posted to a chan. It had url logging capabilities which work fine; however, it outputted the urls to an eggdrop log file. I want the URL's to be visible on a website, so I came up with that code. I want each url posted to be inserted into the top of the file, not appended at the bottom
_________________
irc://irc.efnet.net/peakoil
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Sat Oct 27, 2007 11:43 am    Post subject: Reply with quote

Ok, sorry, I didn't look completely your code.
Peharps your variable is too big for the system, you can try adding each $uline with a foreach loop.
I know this trouble exists with exec command when the string is too long, so try this way.
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
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