If I want to send a string over TCP in a shell environment, I can do something like:
echo text | nc 1.2.3.4 9876
Cool. Interactively, that works. Now I want to do this programmatically by spawning a subprocess from another program, so I want to avoid using a shell and pipes.
But nowAlso, suppose I have asince I'm deploying with distroless Docker environmentcontainers without any shell, thus no echo or pipethey don't come with a shell.
Is there an existing tool to send an command line argument as string over TCP? I'm looking for aan (imaginary) variant of nc like, e.g.:
nc 1.2.3.4 9876 text
that does the same as the above.
echo text | nc 1.2.3.4 9876
(Need the output too.)
I'm about to write my own application for this, but I can imagine this exists already, simply taking one of the argv instead of stdin to pass on.
Looked at socat, which can read from files with OPEN, which is very close to what I want, but I need the string to be passed as parameter from the command lineissued.
For the full context, the entrypoint of the Docker container should be settable by it, without shells or other interpreted language, but pure OS native dependencies like glibc (like socat/nc is!).