Sending operations to device

What product/components do you use and which version/fix level are you on?

Cumulocity IoT v 10.13

Is your question related to the free trial, or to a production (customer) instance?

Customer instance

What are you trying to achieve? Please describe it in detail.

I am looking to send OS commands to a device. For instance, I want to send the command to a Windows device of “mkdir c:\users\public\testdir”

Do you get any error messages? Please provide a full error message screenshot and log file.

  • Failure reasonUnhandled exception. exception=[WinError 2] The system cannot find the file specified
  • DescriptionExecute shell command: Test command
  • StatusFAILED
  • Result-

I can send the command “show help” and I get this response:

  • DescriptionShell command
  • StatusSUCCESSFUL
  • Resultshow packages show processes show memory show cpu-usage show disk-usage show agent logs remove apt-lists show logs [ERROR|WARN|INFO|DEBUG] show uptime show uptime since show uptime seconds exec reboot

Have you installed all the latest fixes for the products and systems you are using?

We are on 10.13 - we’re not ready to update to 10.14 yet

The error you are seeing is happening on the device while processing your command. The device agent there is responsible for error handling in this case (see: Device management library - Cumulocity IoT Guides). Can you describe the device agent you are using and what kind of operation you are sending to it?

That makes sense, thanks! I’m using the Python agent available on GitHub. I’m sending mkdir c:\users\public\testdir

The DM-Agent only supports the commands which are shown in the show help output (and on linux OS only).
It can be extended: Adding windows commands here and support could be easily done. You can rebuild the agent afterwards.

Thanks! I’ve found that I can add commands to local/lib/python3.10/site-packages/c8ydm/agentmodules/command_handler.py for Linux and those run after rebooting. For some reason that hasn’t worked on Windows yet…

It depends on how you run the dm-agent. When running from it’s sources (git clone).

pip3 install .
c8ydm.start

the changes should be recognized.

If you run

pip3 install c8ydm

the pre-packaged version from pypi is fetched and installed in

C:\users\<user>\AppData\Local\Programs\Python\<yourPythonVersion\Lib\site-packages

which is overwritten each time a new release if c8ydm is available. So not the proper way to do that.

I would prefer you clone the repo and use the first approach to build your own version of c8ydm.