title: "Command not found" when try to load daemon/agent programatically using system() function on OS X
body: <p>When I try to load some process behalf of another user I receive next error:</p>
  
  <pre><code>sudo: someusername: command not found
  system result: 256
  </code></pre>
  
  <p>Please note that I run it from the process which is running under root.</p>
  
  <p>Here is a code how I do:</p>
  
  <pre><code>        NSString *command = @"sudo someusername /bin/launchctl load -S Aqua /Library/LaunchAgents/com.agent.someagent.plist";
          int result = system([command UTF8String]);
          NSLog(@"system result: %d", result);
  </code></pre>