| View previous topic :: View next topic |
| Author |
Message |
iNFERiON Voice
Joined: 13 Nov 2004 Posts: 7
|
Posted: Wed Nov 30, 2005 11:40 am Post subject: File search problem |
|
|
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 |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Wed Nov 30, 2005 10:29 pm Post subject: |
|
|
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" .
- why do you escape the *? there is no need to . Another tip... if files always have 1 "whitespace" character, you might want to use ? instead of * depending on the exactness the result should be . _________________ 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 |
|
 |
|