Forum Discussion

AlgebraicMirror's avatar
AlgebraicMirror
Icon for Altostratus rankAltostratus
Feb 04, 2016

Do iRules not support the -format switch of the TCL [clock scan] command?

Hi. I'm wondering if anyone has run into this before. I'm attempting to write a time based iRule, which I know others here have done. I am trying to scan in a date from Active Directory that I got with an LDAP query (for simplicity in the example below, I just copied/pasted it into a variable so you can see the exact format).

According to the TCL manual page, the [clock scan] command has a -format switch that can be used to help TCL parse the format of the date being input. Here is an example from the clock scan manual page:

set s [clock scan {2004-10-30 05:00:00} \
       -format {%Y-%m-%d %H:%M:%S} \
       -timezone :America/New_York]

I am trying to do the same thing in my iRule as seen below:

 when ACCESS_POLICY_AGENT_EVENT {
if { [ACCESS::policy agent_id] eq "test_irule" } {
    set pwdLastSet "1/4/2016 9:17:05 AM Eastern Standard Time;"

    set seconds_per_day 86400
    set pwdLastSet_scanned [clock scan $pwdLastSet -format {%D %T %P %z;} -locale en_US]

    [ACCESS::session data set "session.pwdLastSet" $pwdLastSet_scanned]

}

}

Unfortunately, I keep getting an error from the BigIP saying that I have the wrong number of arguments and that "-format" isn't a supported switch. Does anyone have any ideas? Is the F5 [clock scan] command somewhat crippled?

Error:

error_string         : 01070151:3: Rule [/Common/test_irule] error: /Common/test_irule:6: error: [invalid switch: "-format"][-format]

/Common/test_irule:6: error: [wrong args][clock scan $pwdLastSet -format {%D %T %P %;} -locale en_US]

2 Replies

  • Never mind, I just answered my own question. It is somewhat crippled, at least compared to more modern TCL. F5 still only uses TCL 8.4, which doesn't support most of the clock scan options that have been added to the command.
  • Hi AlgebraicMirror,

    your input string is still supported by the TCL8.4

    [clock scan]
    command. Just change the syntax to...

    [clock scan "2004-10-30 05:00:00" -gmt 0]

    ... and adjust the

    -gmt
    option to match your time zone...

    Cheers, Kai