Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

TCL scripted probes on ACE

Hi,

I have two questions about TCP scripts on ACE :

1. TCP source code

How can I browse the TCL source code of predefined probe scripts on the ACE (for instance HTTPCONTENT_PROBE) '

2. Script parameters

How do I retrieve in the TCL script the parameters passed to the script in the command < script script_name [script_arguments] >  ?

Thank you,

Yves

Everyone's tags (3)
1 REPLY
Cisco Employee

Re: TCL scripted probes on ACE

Yves,

you can download all the scripts from the download software page.

http://tools.cisco.com/support/downloads/go/ImageList.x?relVer=A2%283.2%29&mdfid=280557289&sftType=Application+Control+Software+Scripts&optPlat=&nodecount=2&edesignator=null&modelName=Cisco+ACE+Application+Control+Engine+Module&treeMdfId=268437639&tr...

# Copyright (c) 2005-2008 by Cisco Systems, Inc.
#####################################################################

#-------------------------------------------
# debug procedure
# set the EXIT_MSG environment variable to help debug
# also print the debug message when debug flag is on
#-------------------------------------------

proc set_exit_msg { msg } {
    global debug ip port EXIT_MSG

    set EXIT_MSG $msg
    if { [ info exists ip ] && [ info exists port ] } {
        set EXIT_MSG "[ info script ]:$ip:$port: $EXIT_MSG "
    }
    if { [ info exists debug ] && $debug } {
        puts $EXIT_MSG
    }
}

#-------------------------------------------
# main
#-------------------------------------------

# Parse cmd line args and initialize variables
set_exit_msg "initializing variable"
if { $argc <  2 } {
    set_exit_msg "[ info script ] parameters :
"
    exit 30002
}
set ip $scriptprobe_env(realIP)
set port $scriptprobe_env(realPort)
# If port is zero then use well known HTTP port 80
if { $port == 0} {
    set port 80
}

set requestHeader [ lindex $argv 0 ]
set expectFileType [ lindex $argv 1 ]
set debug [ lindex $argv 2 ]
if { $debug == "" } {
    set debug 0
}

# Open connection
set_exit_msg "opening socket"
set sock [ socket $ip $port ]


# Send HTTP request to server
set_exit_msg "sending request : $requestHeader"
puts -nonewline $sock "$requestHeader\n\n"
flush $sock

# Read string back from server
set_exit_msg "receiving response"
set lines [ read $sock ]

# Close connection
set_exit_msg "closing socket"
close $sock


# Parse the HTTP response
# All the following conditions cause probe failure, returning exit code 30002

# Unable to recognize the HTTP response
if { ![ regexp -nocase "^HTTP/1\.\[0-9\] (\[0-9\]\[0-9\]\[0-9\])" $lines match s
tatuscode ] } {
    set_exit_msg "probe fail : can't find status code"
    exit 30002
}

# HTTP response is not 200 OK
if { $statuscode != "200" } {
    set_exit_msg "probe fail : status code is $statuscode"
    exit 30002
}

# Unable to find Content-type header
if { ![ regexp  -nocase  "Content-Type *:(.*)\n" $lines match foundContentType]
} {
    set_exit_msg "probe fail : can't find \'Content-Type\' header"
    exit 30002
}

# Content-type value does not contain the requested string
if { ![ regexp "$expectFileType" $foundContentType]  } {
    set_exit_msg "probe fail : expect content-type \'$expectFileType\', but got
\'$foundContentType\'"
    exit 30002

}

# Indicate probe success with exit code 30001
set_exit_msg "probe success"
exit 30001

1385
Views
0
Helpful
1
Replies