import dry-run inconsistent results (bug?)

I have a test.rsc file with the following contents saved on my router:

/interface wifi
# managed by CAPsMAN
# mode: AP, SSID: iris, channel: 5720/ax/eeeC
set [ find default-name=wifi1 ] configuration.manager=capsman datapath=capdp disabled=no

Running

ssh -t my-router "/import test.rsc verbose=yes dry-run; quit"

(or just

/import test.rsc verbose=yes dry-run

in an interactive terminal) produces the following output

#line 1
/interface wifi
#line 2
# managed by CAPsMAN
#line 3
# mode: AP, SSID: iris, channel: 5720/ax/eeeC
#line 4
set [ find default-name=wifi1 ] configuration.manager=capsman datapath=capdp disabled=no
No syntax errors found in the import file
interrupted

But running

ssh -T my-router "/import test.rsc verbose=yes dry-run; quit"

(notice the use of capital

-T

instead of

-t

, this disables pseudo-terminal allocation, making this a non-interactive ssh session) produces:

#line 1
/interface wifi
#line 2
# managed by CAPsMAN
#line 3
# mode: AP, SSID: iris, channel: 5720/ax/eeeC
#line 4
set [ find default-name=wifi1 ] configuration.manager=capsman datapath=capdp disabled=no
expected end of command (line 4 column 24)
Script Error: found 1 error(s) in import file

So it seems that

dry-run

import changes its semantics based on whether the current shell is interactive or not (which is really weird).

I am on RouterOS 7.16.1 and I have reproduced this bug on both my cAP ax and RB5009UPr+S+IN.

Also,

/export terse

generates the above-mentioned split interface command (with the “managed by CAPsMAN” comment in the middle). It seems to me that terse doesn’t normally insert line breaks in the middle of commands, unlike compact, so this command splitting also might be a separate bug.

P.S. Does Mikrotik have a bug tracker or something?

The line x column 24 corresponds to just before the = sign in “set [ find default-name=”

Could it be that (for whatever reason) the issue is in the path?

I.e. would a one liner work?

/interface wifi set [ find default-name=wifi1 ] configuration.manager=capsman datapath=capdp disabled=no

You can (should) open a support ticket
https://mikrotik.com/support
the more information you can provide, the better.

In second case, each lines are considered not in same session,
so, is obvious that previous /… command is ignored…

This doesn't make sense, because

  1. in this case the /import command reads these lines from the same test.rsc file, not from the stdin of the current session
  2. /import test.rsc (without verbose=yes) works in both cases (no matter if the current session is interactive), so for some reason only the verbose=yes script validation is affected