From: "Ming-Ching Tiew" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Tuesday, April 19, 2005 12:53 PM
Subject: how to use exec and expr


> 
> I have exec and expr included in the instantiate{}. Then
> in mssql.conf, somewhere in the middle I do this :-
> 
>       Acct-Authentic = `%{exec: /bin/echo 123}`
> 
> Then I checked the database and the log files, the values
> for Acct-Authentic did not change accordingly. What am
> I doing wrong ? I must be understanding something wrongly .....
> 

OK I got the attribute changed by using attr_rewrite instead, 
for example,

 attr_rewrite getip 
{
                attribute = Acct-Session-Id
                # search for IP address  aaa.bbb.ccc.ddd
                searchfor = ".*[^0-9]\(\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}\).*"
                replacewith = "\\1"
                append = no
 }

The problem I have is the replacewith string. The way I understand it is
that the replace with is a static string. In my case, I would like to
looking for a match in the string, strip everything else except the 
matched string.

In shell script, it is something like this :-

    .... |  sed -e 's/^.*[^0-9]\(\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}\).*$/\1/'

Note the \1 in the sed command, it strips everything except the matched.
How to do this using the attri_rewrite scheme ?

Cheers




- 
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html

Reply via email to