0

I am doing a telnet connection to the Linux device (using c# code) and execute some commands and in which the command has more than 50 characters. The command is been executed successfully however the telnet response contains a \r\n after ~65 characters which cause the issue.

The script is expecting the response as full command in one line and the output of the command in the next line. However I am getting something like below:

command sent: /root/supplicants/wpa_cli -i p2p0 p2p_peer 00:11:22:33:44:55

Response: /root/supplicants/wpa_cli -i p2p0 p2p_peer 00:1 1:22:33:44:55 00:11:22:33:44:55

How to fix this issue? Why is it adding the \r\n after certain characters?

user3441116
  • 37
  • 1
  • 8

1 Answers1

0

\r\n in a C# string, means a new line (there's a description here too of these). I think what might be happening is that telnet always gives responses formatted as a line with a set maximum length. Could you try adding something to the script which reformats the response, by removing all occurrences of \r\n?

E.g. You can replace these by a blank string, using String.Replace

[EDIT]: I don't know if it's possible to request a response with a different line length. I saw here that there's a toggle clrf option with Telnet, but that might be just for sending a request.

Community
  • 1
  • 1
Kevin C
  • 324
  • 1
  • 14