shazow / ssh-chat

Chat over SSH.
https://shazow.net/posts/ssh-how-does-it-even/
MIT License
5.59k stars 408 forks source link

Send messages on \n and not \r\n #387

Closed minecraftchest1 closed 3 years ago

minecraftchest1 commented 3 years ago

Currently, ssh.chat sends messages when a carriage return newline (\r\n) is sent. This behavior makes it hard to make bots that send output from command line apps that send just \n (essentially any non-windows apps).

shazow commented 3 years ago

It's not hard to add \r to bots. :) There have been dozens of bots written.

\r\n allows for terminals to work, and we're not going to break everything at this point, sorry.

minecraftchest1 commented 3 years ago

That was quick.

minecraftchest1 commented 3 years ago

Any idea on how to get commands like this to work?

tail -f in.txt | java -Xms1024m -Xmx1024m -jar server.jar | tee out.txt | sed '/[^\r]$/{N; s/\n/ /}' | ssh minecraft@192.168.1.40 -p 2022 -T > tmp.txt
shazow commented 3 years ago

Could use something like unix2dos (typically under the dos2unix package).

With sed, you probably want sed s/$/\r/

More here: https://unix.stackexchange.com/questions/153091/how-to-add-a-carriage-return-before-every-newline

shazow commented 3 years ago

Btw you can get cleaner output if you're using our "bot" API. It's under-documented though: https://github.com/shazow/ssh-chat/issues/104#issuecomment-615348534

If you figure it out, a wiki page with a short tutorial would be really appreciated!

minecraftchest1 commented 3 years ago

Could use something like unix2dos (typically under the dos2unix package).

With sed, you probably want sed s/$/\r/

More here: https://unix.stackexchange.com/questions/153091/how-to-add-a-carriage-return-before-every-newline

Searched on bing, but didn't find that answer. Thanks. This thread might still be of some use for some people sitll :)