Telnet in background - TechRepublic
General discussion
February 8, 2001 at 09:33 AM
mis

Telnet in background

by mis . Updated 24 years, 7 months ago

We have a monitoring device that acts as a passthrough for a serial connection to a telnet session. We capture the incoming serial data to a file by opening a telnet session to the device and redirecting telnet’s output to a file. I know, it’s an ugly hack, but believe me we have tried many solutions and this is by far the most reliable.

Unfortunately, reliable does not mean effortless. Every day, someone has to close the telnet capture session, import the data, and start a new capture. All this from the console.

I am trying to semiautomate this by creating a batch file that will 1) kill the existing process, 2) start a new capture, and 3) write the process number of the new capture to a file, so the next time around it can tell which process to kill. Essentially, it says:

kill -s SIGTERM `cat .capturepid`
nohup telnet [address] [port] > [file] &
echo $! > .capturepid

When I try this from the command line, I get a message ‘Connection closed by foreign host’.

Iwant to be able to run this from cron, and never again have to go to the machine to cycle the capture. But there seems to be some difficulty keeping the telnet session live in the background. Why would this be?

Any and all ideas would be appreciated!

This discussion is locked

All Comments