We are doing a prototype of one device, where our central controller is running on RPi. Since we want it to automatically execute one application straight out of the box, without plugging anything in or triggering anything on command line, we run it in the bootscript in init.d.

The script works ok and the binary does too. Weird things happen when the file is saved when we quit (have a red button on GPIO) the binary and it saves the file (an XML file, we use pugixml). When we run this on the command line manually, logged in as user "pi", everything works. But when the script is automatically started, everything is of course run in sudo (which is the requirement anyway for the wirinPi library for GPIOs and serials) and works okay, but the xml file is saved to root ("/") with corrupted data. The path for file is okay and script works okay when triggered on command line manually.

Is there any workaround for this, i.e logging in as a pi as here In general, what is the root (no pun intended) cause of this?

migrated from stackoverflow.com Apr 2 '15 at 15:09

This question came from our site for professional and enthusiast programmers.

  • 1
    Please show your code that saves the XML file. – infused Mar 31 '15 at 22:19
  • Thanks, it is a SW question first, but I will move. For the code example, I need to show the script probably, because I am giving the path to the pugixml library. – arapEST Apr 2 '15 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy