Home/Support/Support Forum/XOS: "python -c cmd" not supported (works on SarOS)
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

XOS: "python -c cmd" not supported (works on SarOS)

0 votes
Hi, to allow remote scripting on the LR54 over ssh it would be really nice to have the ability to pass python code as arguments to the "python" command. This is possible on the older LR routers running SarOS.


Example that works on SarOS, but not XOS:

digi.router> python -c "print(1+2)"
## Invalid filepath

Example use case for automation:

bash$ ssh digi.router -- python -c \"print\(1+2\)\"

Can this be implemented in the next updates? Or is there an alternative way to execute python code using the cli without uploading a python file?

Alternative (inconvenient) ways I've explored:

1. Can run python interactively and paste (or use expect) into the repl, but only works if done over an interactive terminal. Not possible directly over ssh.

2. Create a wrapper that runs exec(sys.arg[1]) and prefix the command with that wrapper. Does not work after factory reset, since the file needs to be uploaded to the router before.
asked Jun 26, 2018 in Python by stigogo New to the Community (2 points)

Please log in or register to answer this question.

1 Answer

0 votes

The previous version of the OS was actualy TLR and not SAROS this is only on the WR11/21/31/41/44

I dont see them doing any changes to the python command in XOS

What type of commands are you trying to run over SSH could you not build your own socket server in python to run other commands as needed?
answered Mar 4, 2019 by James.Wilson Veteran of the Digi Community (1,227 points)