How to write and read string to serial port from script?

subj

I don’t about receiving from the serial port, but you can send commands with this workaround: http://wiki.mikrotik.com/wiki/Sending_text_out_over_a_serial_port

This article might also be informative: http://wiki.mikrotik.com/wiki/Serial_Port_Usage

Thanks.

This is half of what I wanted…
Is there anyway to check the response after issuing a text string like this?

My project is simple, I want to use the Serial0 port to send out “data” a string, a character, whatever it is, and check the response back to see if it was the same or anything really. Oe perhaps check if the “null Modem is linked?”

I want to use the serial0 port to connect a switch for a door contact, when the door is closed ( Actually a rack cabinet door) it will send out data, or check to see if this is connected, but when the cabinet door opens, the switch is opened as well, in turn disconnecting the DATA TX AND RX thus no data is send back to its own port.

Is there a way to do this with the sending of a text string, or to check the status of the serial0 port if it is even connected?

The end goal is to send an EMAIL if the switch is opened. Crude cheap security alarm. I do know I can get an Ethernet device that I can plug in, but I have no ports left on that RB.

Thanks.

ADDED:

Bored out of my mind… so I thought of an idea, is it possible to allow Special user to log in and to use the serial port, and then have a script that will telnet to itself internally ( IE telnet to its own IP ) and then send a command via telnet, and read the result, and if the echo back matches, then the “door is closed” but if there is no echo back the door switch is open.

This script could be set to run how ever often one would like.

Run script, Telnet with “special user” to own routerboard or another one if u wish, then send text, and read reply ( Which is the same since TX and RX pins are crossed on the serial port) and then if value is correct, do nothing, if no return of data /tool send email…

Am I onto something here?