Forum Discussion
Parse data w/white spaces
While still searching for a way to make this dynamic, I was permitted to hard-code it temporarily. I wanted to post what I have with questions.
The findstr command includes a blank space after each data field I needed to insert and caused the header inserts to fail. So, I added a trim command to remove the space. Is there a way to make this a one-line command?
Also, I need to insert the headers on a Permit or Deny status. How do I do that w/out duplicating the code as I'm currently doing?
($recv_data excerpt:)
Some_More_Data1: cn=last first middle initials, ou=xxx,ou=yyy,ou=zzz,o=aaa,c=bb Some_More_Data2: xxx Some_More_Data3: yyy Some_More_Data4: zzz status=Permit
set Some_More_Data1 [findstr $recv_data "Some_More_Data1:" 15 "Some"
set Some_More_Data1_trim [string trim $Some_More_Data1]
set Some_More_Data2 [findstr $recv_data "Some_More_Data2:" 15 "Some"
set Some_More_Data2_trim [string trim $Some_More_Data2]
set Some_More_Data3 [findstr $recv_data "Some_More_Data3:" 15 "Some"
set Some_More_Data3_trim [string trim $Some_More_Data3]
if {$recv_data contains "permit" } {
HTTP::header insert insert Some_More_Data1 $Some_More_Data1_trim
HTTP::header insert insert Some_More_Data1 $Some_More_Data2_trim
HTTP::header insert insert Some_More_Data1 $Some_More_Data3_trim
log local0. "Inserted Some_More_Data1 $Some_More_Data1_trim
log local0. "Inserted Some_More_Data2 $Some_More_Data1_trim
log local0. "Inserted Some_More_Data3 $Some_More_Data1_trim
}
else {
HTTP::header insert insert Some_More_Data1 $Some_More_Data1_trim
HTTP::header insert insert Some_More_Data1 $Some_More_Data2_trim
HTTP::header insert insert Some_More_Data1 $Some_More_Data3_trim
log local0. "Inserted Some_More_Data1 $Some_More_Data1_trim
log local0. "Inserted Some_More_Data2 $Some_More_Data1_trim
log local0. "Inserted Some_More_Data3 $Some_More_Data1_trim
}
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com