# Write value in mangOH /sys files

**URL:** <https://mangoh.discourse.group/t/write-value-in-mangoh-sys-files/4717>\
**Category:** mangOH Yellow\
**Created:** [June 25, 2020, 10:13am UTC](https://mangoh.discourse.group/t/write-value-in-mangoh-sys-files/4717 "2020-06-25T10:13:05Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![paulmeis](https://avatars.discourse-cdn.com/v4/letter/p/c57346/32.png) [@paulmeis](https://mangoh.discourse.group/u/paulmeis)\
**Post date:** [June 26, 2020, 10:32am UTC](https://mangoh.discourse.group/t/write-value-in-mangoh-sys-files/4717/6 "2020-06-26T10:32:07Z")

</div>

> Blockquote  
> When using unsandboxed application, you need to specify the full path when fopen() .

I did that, but i had the same error (Bad file descriptor).

But I tried (in unsandboxed mode) to use `open` instead of `fopen` and `write` instead of `fprintf` and it worked ! If anyone is interested, here is my code:

```auto
#include "interfaces.h"
#include "legato.h"
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

COMPONENT_INIT
{
    int rc;
    int fp = open("/sys/bus/i2c/devices/6-0068/iio:device0/in_accel_sampling_frequency", O_RDWR);

    if (fp < 0)
    {
        LE_ERROR("Error openning the file (errno=%d, err_msg=\"%s\")\n", errno, strerror(errno));
        return LE_NOT_FOUND;
    }

    rc = write(fp, "100", strlen("100"));
    if (rc < 0)
    {
        LE_ERROR("Error writing accelerometer configuration (errno=%d, err_msg=\"%s\")\n", errno,strerror(errno));
        return LE_NOT_POSSIBLE;
    }
}

```

Keep in mind your app needs to be in **unsandboxed** mode for this to work !

Thanks for your help, have a good day !

---

_[View the full topic](https://mangoh.discourse.group/t/write-value-in-mangoh-sys-files/4717)._
