As a spin off to this Stack Overflow question I want to archieve the same except for a couple of tweaks.
I want to connect to a host, send a binary file, line by lin
After a lot of trying and pulling my hair I finally figured out that I could use NCat instead of Netcat as NCat can execute a command.
Start a connection with NCat to my socket server on port 5000
and execute the script ./sendlines.sh
:
ncat --exec "./sendlines.sh" 192.168.1.10 5000
./sendlines.sh
will send 4 lines with a delay of two seconds between each line:
#!/bin/bash
#
# sendlines.sh, v1.00, initial release
#
i="0"
while [ $i -lt 4 ]
do
echo -ne "\x00e\x00\x0000370513,6598,no,8,,2z\x00"
sleep 2
i=$[$i+1]
done
I have not figured out how to send a binary file, line by line, but this is not strictly necessary as I can manage by sending the same string many times.
If you know a way to send a binary file, line by line, it would be great as it would be the best solution for me.