| View previous topic :: View next topic |
| Author |
Message |
honeybee Halfop
Joined: 01 Jan 2006 Posts: 80
|
Posted: Mon May 08, 2006 10:19 pm Post subject: getting problem with matching pattern. |
|
|
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: | foreach user [userlist ] {
foreach host [getuser $user hosts] {
if {![string match -nocase $host $uhost]} { do something } |
|
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Tue May 09, 2006 2:03 am Post subject: |
|
|
$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] tag when posting logs, code |
|
| Back to top |
|
 |
honeybee Halfop
Joined: 01 Jan 2006 Posts: 80
|
Posted: Tue May 09, 2006 5:21 am Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
honeybee Halfop
Joined: 01 Jan 2006 Posts: 80
|
Posted: Tue May 09, 2006 3:39 pm Post subject: |
|
|
| any help please? |
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Wed May 10, 2006 6:34 am Post subject: |
|
|
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... |
|
| Back to top |
|
 |
honeybee Halfop
Joined: 01 Jan 2006 Posts: 80
|
Posted: Wed May 10, 2006 6:32 pm Post subject: |
|
|
Ok fine, [lindex [split $uhost @] 1] will return with the host and then i match it with the
| Code: | 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 | Quote: | | ![string match -nocase "$userhost" $host] |
|
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Wed May 10, 2006 8:18 pm Post subject: |
|
|
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 _________________ 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...
Last edited by De Kus on Thu May 11, 2006 4:05 am; edited 2 times in total |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Wed May 10, 2006 8:51 pm Post subject: |
|
|
| De Kus wrote: | | a) foreach uses 3 arguments only |
Not necessarily:
| Quote: | NAME
foreach - Iterate over all elements in one or more lists
SYNOPSIS
foreach varname list body
foreach varlist1 list1 ?varlist2 list2 ...? body |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
honeybee Halfop
Joined: 01 Jan 2006 Posts: 80
|
Posted: Thu May 11, 2006 7:37 pm Post subject: |
|
|
| Ok thanks i did it myself. |
|
| Back to top |
|
 |
|