0

I'm not sure what is going on or which command causes the unexpected behavior, so I'll post everything I've done:

I have created a script onreceive.sh containing:

#!/bin/bash
read INCOMING
wall --nobanner "${INCOMING}.wav"
wall --nobanner "${INCOMING}"

Then I ran:

socat -u tcp-listen:7777,fork system:./onreceive.sh

Then I made a connection (I used PuTTY, but netcat probably works as well) to port 7777 and sent one line of text ("asdf").

The output I got is:


.wav


asdf


What I expected:


asdf.wav


asdf


AndreKR
  • 1,010
  • 3
  • 13
  • 28
  • Works fine for me. It may be down to how you connect. I'm not familiar with putty, but I thought it was a ssh client. You may want to add a few `-d` options and maybe `-v` as well to to socat debug. And also possibly use `socat -d -d -d -v - tcp:host:7777` for the client. – Stéphane Chazelas Oct 04 '21 at 05:37
  • 1
    Your input ends with a carriage return. – Michael Homer Oct 04 '21 at 05:47
  • @MichaelHomer Ooooh, you mean a CR *without* an LF? That could explain the result, yes. – AndreKR Oct 04 '21 at 13:50
  • @MichaelHomer Yes, that was it, I confirmed it with a longer string. It's probably because `read` strips the LF but keeps the "unknown" CR? – AndreKR Oct 04 '21 at 13:52

0 Answers0