Skip to content
Advertisement

Simplest way to script slowly sending data through a socket connection

I need to periodically connect to a server from a Linux client and send some commands, so I wrote this script:

JavaScript

The problem is that I need to wait between commands. This script sends the commands and disconnects too quickly, which the server detects, and drops the commands. It works if I open the connection from the command line and then paste the commands one at a time, and it works from non-local clients, but from local clients the script fails. It would be enough to just pause for a second or so between each command.

I can write a C or Java program that does this, but what is the simplest way? The usual scripting languages (Perl and Python) are available, if you need them.

Advertisement

Answer

Shell commands to echo a line at a time from a file to telnet:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement