# Sending operations to device

**URL:** <https://community.cumulocity.com/t/sending-operations-to-device/5300>\
**Category:** Forum\
**Tags:** cumulocity\
**Created:** [October 19, 2022, 3:05pm UTC](https://community.cumulocity.com/t/sending-operations-to-device/5300 "2022-10-19T15:05:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![david.presuhn](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/david.presuhn/32/32123_2.png) [@david.presuhn](https://community.cumulocity.com/u/david.presuhn)\
**Post date:** [October 19, 2022, 3:05pm UTC](https://community.cumulocity.com/t/sending-operations-to-device/5300/1 "2022-10-19T15:05:48Z")

</div>

#### 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

---

<div class="post-metadata">

**Author:** ![Philipp\_Emmel](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/philipp_emmel/32/19455_2.png) [@Philipp\_Emmel](https://community.cumulocity.com/u/Philipp_Emmel)\
**Post date:** [October 19, 2022, 3:26pm UTC](https://community.cumulocity.com/t/sending-operations-to-device/5300/2 "2022-10-19T15:26:04Z")

</div>

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](https://cumulocity.com/guides/reference/device-management-library/#error-handling-during-operation-processing)). Can you describe the device agent you are using and what kind of operation you are sending to it?

---

<div class="post-metadata">

**Author:** ![david.presuhn](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/david.presuhn/32/32123_2.png) [@david.presuhn](https://community.cumulocity.com/u/david.presuhn)\
**Post date:** [October 19, 2022, 3:47pm UTC](https://community.cumulocity.com/t/sending-operations-to-device/5300/3 "2022-10-19T15:47:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Stefan\_Witschel](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/stefan_witschel/32/31955_2.png) [@Stefan\_Witschel](https://community.cumulocity.com/u/Stefan_Witschel)\
**Post date:** [October 19, 2022, 4:27pm UTC](https://community.cumulocity.com/t/sending-operations-to-device/5300/4 "2022-10-19T16:27:02Z")

</div>

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.

> <https://github.com/Cumulocity-IoT/cumulocity-devicemanagement-agent/blob/main/c8ydm/agentmodules/command_handler.py>

---

<div class="post-metadata">

**Author:** ![david.presuhn](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/david.presuhn/32/32123_2.png) [@david.presuhn](https://community.cumulocity.com/u/david.presuhn)\
**Post date:** [November 1, 2022, 1:58pm UTC](https://community.cumulocity.com/t/sending-operations-to-device/5300/5 "2022-11-01T13:58:31Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![Stefan\_Witschel](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/stefan_witschel/32/31955_2.png) [@Stefan\_Witschel](https://community.cumulocity.com/u/Stefan_Witschel)\
**Post date:** [November 1, 2022, 2:39pm UTC](https://community.cumulocity.com/t/sending-operations-to-device/5300/6 "2022-11-01T14:39:37Z")

</div>

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

```auto
pip3 install .
c8ydm.start

```

the changes should be recognized.

If you run

```auto
pip3 install c8ydm

```

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/system/32/31990_2.png) [@system](https://community.cumulocity.com/u/system)\
**Post date:** [April 30, 2023, 2:39pm UTC](https://community.cumulocity.com/t/sending-operations-to-device/5300/7 "2023-04-30T14:39:53Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
