04-02-2007 02:58 AM
Hi,
I am trying to execute the following script, this script is testing connectivity on multiple hosts and TCP ports to define a service as 'up'
#!name = CHECKPORT_STD_SCRIPT
########################################################################################
#
# Scriptname : CheckPortsTask.tcl
# Pamapaters : <list of hosts ip >
# <list of ports >
# [verbose] optional verbose debug flag.
#
# Description :
# This is an example of standalone script. The script is given a list of hosts
# and a list of posrts for each host. The script then checks to see if the host:port
# is available and listening.
#
# Example execution:
# script task 1 "10.2.0.12 10.2.0.14 10.5.0.15" " 21 23 80 2048"
#
#
#
########################################################################################
proc ck_puts { msg } {
puts "[ info script ] : $msg"
}
#-------------------------------------------
# main
#-------------------------------------------
# parse cmd line args and setup ip , port
if { $argc != 2 } {
ck_puts "paramaters: script task <id> [ info script ] <hostList> <portList>"
exit -1
}
set hostList [ lindex $argv 0 ]
set portList [ lindex $argv 1 ]
ck_puts "================= test start========================="
foreach ip $hostList {
ck_puts "----------------- host $ip-------------------------"
foreach port $portList {
ck_puts "testing $ip:$port"
if { [catch { socket $ip $port } sock ] } {
ck_puts "\t$ip:$port ERR : $sock"
if { [ regexp "connection timed out" $sock ] } {
## erro due to connection timeout, skip to next ip
break;
}
## other error, don't break, keep test next port for the same ip
} else {
ck_puts "\t$ip:$port OK"
close $sock
}
}
}
ck_puts "================= test end========================="
My issue is that the comments suggest the arguements are put into 2 sections of quotations but the CSS will not allow this input....
CSS11503(config-service[TEST-SERVICE])# keepalive type script checkportstask ?
<cr> Execute command
use-output Allow tools such as grep to parse script output
<Quoted text> Script Arguments (Len: 0-128)
CSS11503(config-service[TEST-SERVICE])# keepalive type script checkportstask
CSS11503(config-service[TEST-SERVICE])# keepalive type script checkportstask "10.1.1.1 10.2.2.2" "80 443"
^
%% Invalid input detected at '^' marker.
CSS11503(config-service[TEST-SERVICE])#
Can anyone shed some light on how this script is executed.
Thanks,
Brian
04-02-2007 05:50 AM
what you show is a CSM/ACE TCL script.
The CSS uses its own scripting language.
More info @
BTW, what you need already exists.
http://www.cisco.com/en/US/products/hw/contnetw/ps792/products_tech_note09186a00801e1e14.shtml
Gilles.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide