Specifying startup commands with socat

1

I'm connecting to a simple server which is offering a basic text-based interface using socat like this

socat readline TCP4:localhost:8090

There are some initial commands I have to execute every time I connect, and I would like to automate this. Is there some way to have socat execute these automatically before going back to readline-mode? Or is there some other program better suited to this purpose?

Benno

Posted 2012-06-13T12:45:13.963

Reputation: 229

Answers

2

A simple script can be written:

#!/usr/bin/env bash
exec {fd}<>/dev/tcp/127.0.0.1/8090
echo "command" >&$fd
echo "other command" >&$fd
exec socat readline fd:$fd

user1686

Posted 2012-06-13T12:45:13.963

Reputation: 283 655