How to send a string to serial port via /special-login

Hello,
I set up the user account which is bound to serial port by special-login feature. Well, now I can send a string to device connected to this port when I a’m logged in under the respective account. This is good.

I would like to automate this process by some script AND get reply string back. I failed to pass the string to port by the command like this: echo “string” | ssh -l port-user ip.add.re.ss.

Any idea how send a a string in and get reply out via the ssh script?

Thanks
Martin Calko

i dont think the ssh shell will allow you to do this easily. How about using netcat and the /port remote-access feature? That lets you communicate directly to a serial port over tcp/ip without logging in. Maybe you can use some firewall filters to secure it.

Well, I tested this:
/port remote-access add allowed-addresses=0.0.0.0/0 channel=0 disabled=no log-file=“” port=serial-usb-1 protocol=rfc2217 tcp-port=3333

and then from linux:
> echo “*B$?” | netcat -n -vv 3333
(UNKNOWN) [routerboard-ip] 3333 (?) open
sent 5, rcvd 0

and in logfile on routerboard appears this:
/log pri
14:01:15 sertcp,info connection to serial remote-access 0.0.0.0:3333 from :46409
14:01:44 sertcp,info connection to serial remote-access 0.0.0.0:3333 from :46410
14:01:49 sertcp,info connection to serial remote-access 0.0.0.0:3333 from :46411
14:01:51 sertcp,info connection to serial remote-access 0.0.0.0:3333 from :46412
14:02:05 sertcp,info connection to serial remote-access 0.0.0.0:3333 from :46413
14:02:07 sertcp,info connection to serial remote-access 0.0.0.0:3333 from :46414
14:02:14 sertcp,info connection to serial remote-access 0.0.0.0:3333 from :46415

but device connected to routerboard’s port does nothing. The same command string entered under /sys serial-terminal port=serial-usb-1 seems working correctly.

Any idea what is wrong? Should be connection opened some special way?

try setting protocol to raw on the mikrotik? also, maybe enable telnet negotiation on netcat, if you didnt already. Im not in front on a machine to check those parameters.