import librouteros api = librouteros.connect('192.168.100.2', 'mi4', 'm14', port=8728) items = list(api('/system/scheduler/print')) for item in items: if item['name'] == 'Bulanan2': oid = item['.id'] print(f'Bulanan2 .id = {oid}') print(f'on-event len = {len(item["on-event"])}') # Try setting via different .id formats test_cmds = [ # Test 1: numeric id with comment ('comment', f'TEST_{oid}'), ] for field, val in test_cmds: api('/system/scheduler/set', **{'.id': oid, field: val}) # Verify comment items = list(api('/system/scheduler/print')) for i in items: if i['name'] == 'Bulanan2': print(f'Comment after: {i.get("comment")}') # Test: set on-event with simplest possible script print(f'\nSetting on-event with no special chars...') try: api('/system/scheduler/set', **{'.id': oid, 'on-event': 'put hello'}) except Exception as e: print(f' ERROR: {e}') # Re-read items = list(api('/system/scheduler/print')) for i in items: if i['name'] == 'Bulanan2': oe = i.get('on-event', '') print(f'on-event now: {oe[:60]}') print(f'Changed: {oe != item["on-event"]}') # Test: set on-event with : character print(f'\nSetting on-event with colon...') try: api('/system/scheduler/set', **{'.id': oid, 'on-event': ':put "hi"'}) except Exception as e: print(f' ERROR: {e}') items = list(api('/system/scheduler/print')) for i in items: if i['name'] == 'Bulanan2': oe = i.get('on-event', '') print(f'on-event now: {oe[:60]}') expected = ':put "hi"' print(f'Changed to :put: {oe == expected}') # Restore comment api('/system/scheduler/set', **{'.id': oid, 'comment': 'Monitor Profile Bulanan2'}) break api.close()