Forum Discussion

Andrés_Ortiz_10's avatar
Andrés_Ortiz_10
Icon for Nimbostratus rankNimbostratus
Aug 13, 2007

client introduces caracters in ldap search

Hi,

 

 

I have a problem with the format wich I received the first octet of the ip address of the filter in this search ldap:

 

 

 

ldapsearch -h 10.16.13.52 -p 389 -b =SIUX "LOGIN=99.222.222.222" MSISDN

 

 

I capture the first octet using the command :

 

 

set Octeto_Uno [getfield $LoginIP "." 1 ]

 

 

but sometimes $Octeto_Uno has not a integer, the client introduces caracters. I don´t know how to erase this caracters to obtain only the integer number cause when i show $Octeto_uno:

 

 

log local0. "Octeto_Uno= $Octeto_Uno"

 

 

I can`t see the caracters, only the number in all cases, but when i try :

 

 

set Uno [expr {$Octeto_Uno*2}]

 

 

this error message appears:

 

can't use non-numeric string as operand of "*" while executing "expr {$Octeto_Uno*2}"

 

 

 

Any idea to resolve this?

 

 

thanks in advantage.

1 Reply

  • Hello,

     

     

    'string map' doesn't seem to accept wildcards, so the best option I can think of would be to use regsub.

     

     

    Here's an example:

     

     

    % set mixed_string abcd1234abcd

     

    abcd1234abcd

     

    % set digits [regsub -all {[a-zA-Z]} $mixed_string ""]

     

    1234

     

     

    Here are a few related manual pages:

     

     

    string Click here

     

    regsub Click here

     

     

    Else, you might be able to use scan:

     

     

    scan Click here

     

     

    Aaron