-1

I need to send the following commands to a busybox device via a serial port:

SBC1000 > setenv serverip '192.168.128.100'
SBC1000 > setenv fsfile '1k\root.jffs2-128k'
SBC1000 > saveenv

I can escape the single quotes of the first line without a problem using a backslash:

cmd = 'setenv serverip \'192.168.128.100\''

I've tried various combinations of backslashes for the second line, but couldn't get the 1k\root part to escape properly. I believe it is being interpreted as a return. I tried double and triple escape with no success.

I finally stumbled upon using

cmd = 'setenv fsfile \'1k\\\u0072oot.jffs2-128k\''

to include the \r ( not a return ) for my string.

Is there a more readable way to include this \r ( not a return ) pattern in my string?

Phil Brooks
  • 643
  • 4
  • 8
  • Did you try `cmd = "setenv fsfile '1k\\root.jffs2-128k'"`? Or use a raw string: `cmd = r"setenv fsfile '1k\root.jffs2-128k'"` – John Szakmeister Mar 08 '19 at 19:02
  • I found this thread [here](https://stackoverflow.com/questions/31624041/print-n-or-newline-characters-as-part-of-the-output-on-terminal), might solve it. Can't try it myself rn. – Aeossa Mar 08 '19 at 19:06

1 Answers1

-1

The solution was to use double-quotes " " as suggested by John Szakmeister.

I discovered that the command string was being passed to a function inside a private class based on pexpect-serial.

My guess is that my string was being evaluated by pexpect in a greedy way. By using a distinct delimiter, the problem was overcome.

Phil Brooks
  • 643
  • 4
  • 8