title: return code of 256 from python
body: <p>This is a reposted question from raspberrypi.stackexchange.com. While I am trying to get something to work on python on the raspberry pi, since it doesn't involve any pi-specific things, it was suggested by someone I post here instead. Original post is <a href="https://raspberrypi.stackexchange.com/questions/9894/return-code-of-256-from-python">here</a>.</p>
  
  <hr>
  
  <p>I am trying to make a web ui to change the date in the rapsberry pi, but I keep getting a return code of 256.</p>
  
  <p>Currently what I have goes like this:</p>
  
  <p>web page -> submits an ajax request to a python script
  python checks what type of command (a time/date command in this case) and pieces together a string looking like:</p>
  
  <pre><code>sudo date --set="20130901 20:10"
  </code></pre>
  
  <p>and stores it in a variable <code>commandString</code>. Then python goes:</p>
  
  <pre><code>os.system(commandString)
  </code></pre>
  
  <p>and the return value is passed all the way up to the web ui where it is printed out.</p>
  
  <p>I also currently return the <code>commandString</code> value to the web ui too to verify it and it looks okay.</p>
  
  <p>The problem is that every time I test, I keep getting back 256 as the error return code. The date on the raspberry pi of course doesn't change as I manually check it before and after. </p>
  
  <p>However, if I manually go in to python on the raspberry pi and try:</p>
  
  <pre><code>commandString = 'sudo date --set="20130901 20:10"'
  os.system(commandString)
  </code></pre>
  
  <p>It works with no issues. If I try it without <code>sudo</code> then I get a return value of 256 as well, so I thought maybe it was a permissions issue with my original script. I tried <a href="https://stackoverflow.com/questions/2806897/what-is-the-best-practices-for-checking-if-the-user-of-a-python-script-has-root">this link</a> to check my script's permissions and it seems to be okay? (<code>os.geteuid()</code> is 0)</p>
  
  <p>If it matters, I am using lighttpd and fastcgi to run python from a web ui. My lighttpd config is currently:</p>
  
  <pre><code>fastcgi.server = (
      ".py" =&gt; (
      "python-fcgi" =&gt; (
      "socket" =&gt; "/tmp/fastcgi.python.socket",
      "bin-path" =&gt; "/var/www/command.py",
      "check-local" =&gt; "disable",
      "max-procs" =&gt; 1)
      )
  )
  </code></pre>
  
  <p>Any ideas on what I'm missing?</p>
  
  <hr>
  
  <p>On the original post, it was also suggested I try something like:</p>
  
  <pre><code>echo &lt;password&gt; | sudo -S date --set="20130829 02:02
  </code></pre>
  
  <p>While it's probably not a good idea to put in my root password like that, I tried it and got the same result: it works when doing in the terminal/shell and within the python interpreter, but not via the web ui to python.</p>