Run script on command-line

Hi, I am new on OTII Automation toolbox

I need to launch a python script without open manually OTII soft. For this :
I open command-line and type : otiicli -s example_basic_function_check.py’

And after that, I cannot write anything without quitting the server listening. So I can’t launch my script. This is the same reaction for ‘otiicli -s’
I also tried ‘otiicli example_basic_function_check.py’ but it doesn’t work without start server listening before.

Do you have some advice to help me ?
Thanks !

Hi, problem solved

I didn’t see the following link : Qoitech Documentation, it was very helpful. Thanks.

Just a comment in " Start otiicli from Script" chapter :
I imported subprocess : import subprocess
I pasted the following script part and changed my USERNAME and PASSWORD by mine:

cmd = f'otiicli --server --username={USERNAME} --password={PASSWORD}'
server = subprocess.Popen(cmd, shell=True)

Then, I used those lines :

connection = otii_connection.OtiiConnection(cfg.HOST["IP"], cfg.HOST["PORT"])
connect_response = connection.connect_to_server()
if connect_response["type"] == "error":
    print("Exit! Error code: " + connect_response["errorcode"] + ", Description: " + connect_response["data"]["message"])
    sys.exit()

It permits to make no change on Host IP and Port comparing to the given script.
Maybe this will help someone !

I forgot :
for the second lines, we must add : import example_config as cfg
the example_config.py script :

#!/usr/bin/env python
HOST = {
    # IP address of the server
    "IP":"127.0.0.1",
    # Port number the server is listening on
    "PORT":1905
    }

Hi,

Thank you for posting this!

Best regards,
Björn