Chapter 8 Using the CSS Scripting Language
Script Keepalive Examples
8-56
Cisco Content Services Switch Administration Guide
OL-5647-02
Time Keepalive
!no echo
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Filename: ap-kal-time
! Parameters: HostName
!
! Description:
! This script will connect to a remote host 'time' service on
! port 37 and get the current time. This script currently works
! strictly with TCP. [Ref. RFC-868]
!
! Failure Upon:
! 1. Not establishing a connection with the host.
! 2. Not being able to receive incoming data
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Make sure the user has a qualified number of arguments
if ${ARGS}[#] “NEQ” “1”
echo “Usage: ap-kal-time \'Hostname\'”
exit script 1
endbranch
! Defines:
set HostName “${ARGS}[1]”
set EXIT_MSG “Connection Failed”
! Connect to the remote host (use default timeout)
socket connect host ${HostName} port 37 tcp 2000
set EXIT_MSG “Receive: Failed”
! waitfor any data for 2000ms
socket waitfor ${SOCKET} anything 2000
! If the data came in, then we are good to quit
socket disconnect ${SOCKET}
no set EXIT_MSG
exit script 0