Forum Discussion

peet_71253's avatar
Sep 24, 2008

Please help - can't understand error in this case

Very simple irule, basically I want to send to one of two pools based on some criteria.

 

 

In parsing, I get an error:

 

 

line 5: [parse error: PARSE syntax 192 {syntax error in expression " ([HTTP::host] contains "abc.xyz.com") && ([HTTP::cookie] ...": looking for close parenthesis}]

 

 

and:

 

 

line 8: [undefined procedure: else] [else {

 

pool test-old

 

 

the code looks like:

 

 

when HTTP_REQUEST {

 

if { ([HTTP::uri] contains "a.m") || ([HTTP::uri] contains "b.m")} {

 

pool test-new

 

}

 

elseif { ([HTTP::host] contains "abc.xyz.com") && ([HTTP::cookie] exists "cookieid")} {

 

pool test-new

 

}

 

else {

 

pool test-old

 

}

 

}

 

 

 

Sorry to post something so basic, but I've been staring at this for an hour and see all the parends I think are required and am totally stumped by the else error on line 8.

 

 

TIA to all!

 

 

2 Replies

  • Hi,

    I'd first try moving the elseif and else to the same line as the preceding "}":

      
      when HTTP_REQUEST {  
         if { ([HTTP::uri] contains "a.m") || ([HTTP::uri] contains "b.m")} {  
            pool test-new  
         } elseif { ([HTTP::host] contains "abc.xyz.com") && ([HTTP::cookie] exists "cookieid")} {  
            pool test-new  
         } else {  
            pool test-old  
         }  
      }  
      

    If that doesn't work, can you post the new error?

    Thanks,

    Aaron
  • Thanks Aaron - actually the issue was very obvious once I noticed... the HTTP::cookie section shouldn't be in parends, but just in brackets around the statement reading [HTTP::cookie exists "cookiename"]

     

     

    that threw it all off - as it's differen syntaxtually than the other HTTP:: items.