Open mattyloo opened 9 years ago
echo -n "msg \"matty Hey \n Bye\"" | nc.traditional -w 1 127.0.0.1 1234
Thanks for the comment, but its not working. If i use the -n variable nothings comes to the daemon, even this: echo -n msg matty hello | nc.traditional -w 1 127.0.0.1 1234. But if I use -e it comes to the daemon but no line break.
The trick might be to wrap the message in quotes (like "this"
or 'this'
)
If you have "
or '
in you message, you can escape the inner ones with an backslash (\
).
For example:
This is an "example" text.
will become
"This is an \"example\" text."
So your line would be
msg <user> "This is an \"example\" text."
or msg <user> 'This is an "example" text.'
To take it a step further, by wrapping it in the quotes for the echo. But then, just change one type of the quotes to single ones:
echo -n "msg <user> 'This is an \"example\" text.'" | nc.traditional -w 1 127.0.0.1 1234
This works. I use tmux with send-keys. The final message to telegram-cli has ot be "msg chatroom 'this\nis\on\nseparate\nlines' " The key is the alternating ' and " Bash seems to have some trouble differentiating if you have too many nested "s in a row
Hope that helps someone
You have to add more backslashes. (add escaped backslashs \\
after the first one)
"
, \"
, \\\"
, \\\\\"
In the web chat for Telegram you can send line break with Shift + Return so the message will do a break and not send the message.
But i cant find anyway in the linux cli to do that. This not work: echo -n "msg matty Hey \n Bye" | nc.traditional -w 1 127.0.0.1 1234