I am familiar with MikroTik scripting but what I want to do is, have a script that will be able to send an AT command to the modem connected on the board and parse the output given for the command to a variable.
I want to for instance send a USSD (AT+CUSD) command to the modem which will check the account balance of the SIM card in the modem and then use it to email the balance given. I have absolutely no idea how to access the modem and interactively do this via a script.
Any help or pointers in the correct direction will be appreciated.
please see ‘/interface ppp-client’ menu where you can add ppp client for some port, like serial, or, if you have connected some USB port so you can do dial out.
I want to send a command to the modem via interface connected e.g. usb2
The command is something like this:
AT+CUSD=1,“*101#”,15
If I do this command in a terminal on the RouterBoard connected to the modem it works fine. The command is a USSD command that returns the current account balance of the 3G card.
What I want to do now is to do this command via a script and the output of the command must then be parsed and stored in a variable so I can email the contents to someone. How to do the rest, e.g. send the email etc I know how but I do not know how to parse this command’s output that is returned from the ISP back to a variable.
What you do is redirect the terminal to one of the secondary serial ports on the modem (diagnostic or UI ports) as follows:
/system serial-terminal usb2 channel=2
Your usb port and channel may be different, follow the above link for the procedure to list the ports and channels.
You then can send USSD commands directly over the terminal, for example to check your Vodacom balance:
AT+CUSD=1,“111500#”,15
When you are done, disconnect from the modem’s serial port by pressing Ctrl-A followed by Q.