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 

File search problem

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


Joined: 13 Nov 2004
Posts: 7

PostPosted: Wed Nov 30, 2005 11:40 am    Post subject: File search problem Reply with quote

I am writing a script that is supposed to search trough a file on the server and check if a string given by the user exists in it, if so, it should output it. So far, with the help of greenbear on IRC I got this:

Code:
      set query [lrange $text 1 end]
      set query [string map {" " "\*"} $query]
      set srcdb [open users.txt r]
      set data [read -nonewline $srcdb]
      close $srcdb
      set lines [split $data "\n"]
      foreach line $lines {
          if {[string match -nocase "*$query*" $line]} {
             putmsg $chan $line
          } else {
          }
      }


However it does not output any results even if I try it with a query I'm 100% sure is in the database. What am I missing here ?
Back to top
View user's profile Send private message
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Wed Nov 30, 2005 10:29 pm    Post subject: Reply with quote

2 questions:
- why do you use lrange? it looks pointless in your script, since it a) uses a list operation on a string and b) ignores the first entry. esspially the functionality b) could be the cause of your "little problem" Wink.
- why do you escape the *? there is no need to Very Happy. Another tip... if files always have 1 "whitespace" character, you might want to use ? instead of * depending on the exactness the result should be Very Happy.
_________________
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Back to top
View user's profile Send private message MSN Messenger
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