From 4c4441102b47e9249246f626383b89ed2b082092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Goc=C5=82awski?= Date: Tue, 21 May 2024 16:36:17 +0200 Subject: [PATCH] Update README.md Add an example showing how to run a script and get it's output. --- README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c89af36..fc0c11c 100644 --- a/README.md +++ b/README.md @@ -179,7 +179,21 @@ list_queues.remove(id="*2") connection.disconnect() ``` -#### Other Example: +### Run script and get output + +The example script only prints "hello". Here's a simplifed example of how to run it and get the output: + +``` +>>> api.get_resource("/system/script").get()[0]['source'] +'/put "hello"' +>>> async_response = api.get_binary_resource('/').call('system/script/run', {"number": '0'.encode('utf-8')}) +>>> async_response.__dict__ +{'command': , 'done_message': {'ret': b'hello'}, 'done': True, 'error': None} +>>> async_response.done_message['ret'] +b'hello' +``` + +### Other Example: ```python list_address = api.get_resource('/ip/firewall/address-list')