From: Aric Bills on
On 10 mar, 12:00, Don Pich <dp...(a)polartel.com> wrote:
> Thanks to everyone that helped with this problem.
>
> Here is my final tcl script that gave me my desired results:
>
> proc BASCleaner {request response environ} {
> set fp [open "/opt/CSCOar/scripts/radius/tcl/BASIP.list" r]
> set file_data [read $fp]
> close $fp
> set userName [ $request get User-Name ]
> set str1926 [string range $userName 18 25]
> set boolMatch 0
> if {[lsearch $file_data $str1926]>-1} {set boolMatch 1}
> if {$boolMatch == 1} {set newusername [string range $userName 0 end-8]
> $environ put User-Name $newusername
>
> }
> }
>
>

Glad you found a solution that works for you. On a stylistic note,
instead of:

> set boolMatch 0
> if {[lsearch $file_data $str1926]>-1} {set boolMatch 1}
> if {$boolMatch == 1} {set newusername [string range $userName 0 end-8]
> $environ put User-Name $newusername
> }

you can do:

if {[lsearch $file_data $str1926] > -1} {
set newusername [string range $userName 0 end-8]
$environ put User-Name $newusername
}

which is more straightforward.

Best wishes,
Aric
First  |  Prev  | 
Pages: 1 2 3 4
Prev: Compiling
Next: "open" issue in a new defined namespace