alhafoudh / node-red-contrib-mikrotik2

Node-red node to work with Mikrotik WiFi router
ISC License
5 stars 1 forks source link

How to run some script on mikrotik #2

Closed jiribaudys closed 3 years ago

jiribaudys commented 5 years ago

Hi, I send in msg.payload "/system/script/run script1", but if testing lot of variants ('/system/script/run number=script1', some variables text block etc.) will still end on error.

"Error executing cmd[/system/script/run script1]: {"errors":[{"category":"","message":"no such command"}],"channelId":"1","channel":{"id":1,"running":false,"closing":true,"closed":true,"clearEvents":false,"saveBuffer":true,"closeOnDone":true,"lastCommand":["/system/script/run script1",".tag=1"],"_events":{},"_eventsCount":0}}"

jiribaudys commented 5 years ago

Heureka !

Correct execute parametr is "/system/script/run\n=.id=*2" for get .id use "/system/script/print" because .id is not equal "microtick number"

Example: [{"id":"3334d05f.4b224","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"2f3ea815.5e12f8","type":"debug","z":"3334d05f.4b224","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":590,"y":220,"wires":[]},{"id":"5e214184.aa7fd","type":"inject","z":"3334d05f.4b224","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":200,"wires":[["a8c6d908.43b028"]]},{"id":"dcc3acd6.17c6d","type":"mikrotik","z":"3334d05f.4b224","device":"f435f23f.c9718","name":"","action":"9","x":400,"y":360,"wires":[["2f3ea815.5e12f8"]]},{"id":"a8c6d908.43b028","type":"function","z":"3334d05f.4b224","name":"TestGenerator","func":"msg.payload = \"/system/script/run\\n=.id=*2\";\nmsg.topic = \"scritpexecute\"\nreturn msg;","outputs":1,"noerr":0,"x":240,"y":240,"wires":[["dcc3acd6.17c6d","2f3ea815.5e12f8"]]},{"id":"f435f23f.c9718","type":"mikrotik-device","z":"","host":"192.168.1.1","port":"8728","username":"admin","password":"password"}]

jiribaudys commented 4 years ago

Enable / disable firewall filter

[{"id":"7200f1cc.badb","type":"debug","z":"ab9e12bf.20d63","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":630,"y":120,"wires":[]},{"id":"1f9d84a5.0b90eb","type":"inject","z":"ab9e12bf.20d63","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":90,"y":200,"wires":[["e1612a85.b35bc8"]]},{"id":"bc36a1a3.9b8d6","type":"mikrotik","z":"ab9e12bf.20d63","device":"3deb62bd.2d5d7e","name":"","action":"9","x":460,"y":300,"wires":[["7200f1cc.badb"]]},{"id":"e1612a85.b35bc8","type":"function","z":"ab9e12bf.20d63","name":"TestGenerator","func":"msg.payload = \"/ip/firewall/filter/set\\n=.id=*26\\n=disabled=false\";\nmsg.topic = \"scritpexecute\"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":240,"y":240,"wires":[["bc36a1a3.9b8d6","7200f1cc.badb"]]},{"id":"3deb62bd.2d5d7e","type":"mikrotik-device","z":"","host":"192.168.1.1","port":"8728","username":"admin","password":"password"}]

konne commented 3 years ago

@jiribaudys thank -> all-new conversation will be in the here: https://github.com/node-red-contrib/node-red-contrib-mikrotik