0

I'm not able to get the output of command in text file when running this executable of '.c' file:

char image_upload_cmd[100] = {'\0'};

sprintf(image_upload_cmd, "mcumgr conn show > /home/sample/statfile.txt");
system(image_upload_cmd);

--> mcumgr command exists in '/usr/bin/'.
--> conn, show are options to that command.
Vega
  • 27,856
  • 27
  • 95
  • 103
MayankR
  • 25
  • 4

1 Answers1

0

We can use system function to run the command as i mentioned in my question above.

The only problem was that, the board on which i was running this application code required sudo permission for creating that file.

Just add 'sudo' permission as below : sprintf(image_upload_cmd, "sudo mcumgr conn show > /home/sample/statfile.txt");

This will redirect the output to the statfile.txt.

MayankR
  • 25
  • 4