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.

getting problem with matching pattern.

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
h
honeybee
Halfop
Posts: 80
Joined: Sun Jan 01, 2006 12:42 pm

getting problem with matching pattern.

Post by honeybee »

Hey,
I'm again stuck with a part of my tcl.
i m trying to get info from userlist and matchin it with the $uhost and if it doesnt match do something. I don't think i m doing it correctly.

Code: Select all

foreach user [userlist ] {
  foreach host [getuser $user hosts] {
     if {![string match -nocase $host $uhost]} { do something }
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

$uhost means user@host, i.e. no nick; whereas userfile record's HOSTS list is interpreted as consisting of full hostmasks, i.e. nick!user@host

so you need to use *!$uhost instead of $uhost

or use [finduser]
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
h
honeybee
Halfop
Posts: 80
Joined: Sun Jan 01, 2006 12:42 pm

Post by honeybee »

well, i cant use [finduser] cause i want to match *!@$uhost against all the hosts of particular flag let it be +f like [userlist f|f $chan] or something. and if that nick is a validuser [validuser $nick] and his/her *!@$uhost doesnt match with our particular flag's host { do soemthing }, thats what i want to do.
h
honeybee
Halfop
Posts: 80
Joined: Sun Jan 01, 2006 12:42 pm

Post by honeybee »

any help please?
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

hosts are not "user.domain.com" but "*!*@user.domain.com" therefore you need to at least match against "!$uhost". Without ! there will be no match. And if you want to completly ignore any possible entries in host for idents then split them off using [lindex [split $host @] 1].
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...
h
honeybee
Halfop
Posts: 80
Joined: Sun Jan 01, 2006 12:42 pm

Post by honeybee »

Ok fine, [lindex [split $uhost @] 1] will return with the host and then i match it with the

Code: Select all

set host "[lindex [split $uhost @] 1]"
foreach user [userlist o] {
foreach userhost [getuser $user hosts] {![string match -nocase $userhost $host]} { do something }
and i aslo want to ask foreach user [userlist o] { putlog "[getuser $user hosts]"} it returns hosts of the respective flags, is it a string or something or should i use it in "" here
![string match -nocase "$userhost" $host]
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

your quoted line will most likely never be compiled because
a) foreach uses 3 arguments only
b) there is no function called 0 or 1 (you are missing some conditional structure)

PS: you still have a string match that will never be true, because the pattern contains string parts that $host can never ever have.

Edit: then you will get the split string match line as addionatl list elements @_o
Last edited by De Kus on Thu May 11, 2006 4:05 am, edited 2 times in total.
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...
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

De Kus wrote:a) foreach uses 3 arguments only
Not necessarily:
NAME

foreach - Iterate over all elements in one or more lists

SYNOPSIS

foreach varname list body
foreach varlist1 list1 ?varlist2 list2 ...? body
h
honeybee
Halfop
Posts: 80
Joined: Sun Jan 01, 2006 12:42 pm

Post by honeybee »

Ok thanks i did it myself.
Post Reply