K
K
kovalr2019-11-05 22:59:37
Python
kovalr, 2019-11-05 22:59:37

How to redirect telnet log to python script with server drop detection?

There is a task to redirect the telnet log to a Python script.
Implemented as follows:
Using expect, I log in to the server
Then I run <./expect-script.sh | ./mypython-script.sh>
But there is one problem. When the telnet server is rebooted, my script bundle doesn't catch the event and nothing happens.
Example expect script:

#!/usr/bin/expect -f
 
set timeout -1
spawn telnet mytelnet.server
expect "Username: "
send -- "username\r"
expect "Password: "
send -- "Password\r"
expect eof

Python script example:
for line in sys.stdin:
    # some magic
    line = line.rstrip('\n')
    print (line)

How to catch an event when the telnet server is rebooted and nothing gets into the log?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2019-11-05
@dimonchik2013

and nothing is logged

how do you know it's overloaded?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question