Hi,
is it poossible to run a internal defined RouterOS script via API (Python3) external script (command line) ?
I’m trying to enable or disable wireless interface on demand (triggered on external condition).
Return information about successfully switching would be also great.
No SSH needed because all devices (RPi4 and wifi switches) are on local network.
We use some scripts so the RB can control an RPI… so in essence the other way round from what i understand you want to do but I cant see why it wouldn’t work by issuing command from the RPI to the RB
In order to do this you have to give permission to the RB to communicate with the RPI via SSH. I did get some help on this in the past so may be worth taking a look at an old post that helped me a lot.
import paramiko
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect('routerIP', username='myuser', password='mypass')
stdin, stdout, stderr = client.exec_command('/system script run EnableWLAN')
#for line in stdout:
# print(line.strip('\n'))
client.close()
On Mikrotik don't forget to enable SSH port 22 in IP/Services avaliable from a local IP address (pool)
or only from device running above python scripts