home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Columbia Kermit
/
kermit.zip
/
archives
/
ckscripts.tar.gz
/
ckscripts.tar
/
timestamp
< prev
next >
Wrap
Text File
|
2000-05-04
|
2KB
|
56 lines
#!/usr/local/bin/kermit +
#
# t i m e s t a m p
#
# A certain host has a syslogger on its Telnet port. If you telnet
# to it, you see syslog records scrolling by. But the records do not
# have timestamps. This script makes a Telnet connection to the host
# and displays the records with timestamps added. It also appends the
# timestamped records to a file.
#
# Requires: C-Kermit 7.0 or Kermit 95 1.1.18 or higher.
#
# Illustrates:
# . Reading lines of text from a communication connection.
# . Using local files.
# . How to "press any key" to interrupt a loop.
#
# Author: F. da Cruz, Columbia University, May 2000.
.host = syslog.xyzcorp.com ; (*) Replace as needed
.file = console.log ; (*) Remove if logfile not wanted.
set host \m(host) ; Try to make the connection
if fail stop 1 Can't reach \m(host)
if def file { ; If logfile wanted
fopen /append \%c \m(file) ; open it for appending
if fail stop 1 Can't open \m(file)
}
echo \v(date) \v(time): Begin log - Press any key to stop
set quiet on ; Suppress informational messages
set ask-timer 1 ; For sampling keyboard
set input echo off ; We'll handle input echoing ourselves
set command interrupt off ; Disable Ctrl-C
while true { ; Loop to read each record
input -1 \13 ; (*) Replace with \10 if necessary
if fail break
.line := \v(date) \v(time): \ftrim(\v(input),\13\10)
echo \m(line)
if def file fwrite /line \%c \m(line)
clear input
getc \%x
if success break
}
; Come here when a key has been pressed or the connection dropped.
echo \v(date) \v(time): Closing \m(host)...
close connection
echo \v(date) \v(time): Closing \m(file)...
fclose \%c
set command interrupt on
set ask-timer 0
end 0 \v(date) \v(time): Done, bye.