1

I'm trying to get DSR on busybox (to get terminal size), but echo '\x1b[6n' does not report anything, it outputs \x1b[6n.

1

I see two issues:

  1. To make echo handle escape sequences you need to add the option -e. This isn't a speciality of the BusyBox shell, it applies to bash and other implementations, too.
  2. Deducting from this SO question the ANSI code should be \x1b[6n.

Additionally it may be a good idea to suppress the finishing newline. Putting it all together I think the call should look as follows:

echo -en "\x1b[6n"

BusyBox limitations

Older versions of BusyBox don't support \e and \x escape sequences in echo; in this case \033 must be used. This seems to be fixed in 1.23.1.

Make sure to set the following in the configuration:

  • Busybox Settings
    • Busybox Library Tuning
      • Query cursor position from terminal → enabled

SSH/PuTTY limitations

SSH swallows the returned position. To see the answer in your remote terminal you can use

echo -en "\e[6n"; cat

and press Ctrl + C after that.

  • Sorry, missing [ was a typo. I've tried both with or without -e and no success. I have no problem doing it on Linux, but when I copypaste the same code to Busybox, it does nothing. So this is Busybox specific problem. – rebolek Jan 12 '18 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.