title: Trying to send curl POST command in Cocoa App
body: <p>I am trying to use cURL to send a POST request to my Yamaha receiver from a Cocoa application. I am using NSTask to accomplish this and believe I have the syntax correct:</p>
  
  <pre><code>NSTask *task;
  task = [[NSTask alloc] init];
  [task setLaunchPath: @"/usr/bin/"];
  
  NSArray *arguments;
  arguments = [NSArray arrayWithObjects: @"-c", @"curl -v -X POST -H \"Content-type:text/xml\" --data 'xml=&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;&lt;YAMAHA_AV cmd=\"PUT\"&gt;&lt;Main_Zone&gt;&lt;Power_Control&gt;&lt;Power&gt;On&lt;/Power&gt;&lt;/Power_Control&gt;&lt;/Main_Zone&gt;&lt;/YAMAHA_AV&gt;' http://172.19.24.23/YamahaRemoteControl/ctrl", nil];
  [task setArguments: arguments];
  
  [task launch];
  </code></pre>
  
  <p>I have it assigned to a button in my application, it compiles successfully but when I press the button I get this in the log.</p>
  
  <pre><code> 2013-12-06 11:06:27.907 MyApp[18361:303] user clicked powerOnReceiver button
  2013-12-06 11:06:27.909 MyApp[18361:303] Couldn't posix_spawn: error 13
  2013-12-06 11:06:27.911 MyApp[18361:303] (
      0   CoreFoundation                      0x00007fff897c641c __exceptionPreprocess + 172
      1   libobjc.A.dylib                     0x00007fff88e96e75 objc_exception_throw + 43
      2   CoreFoundation                      0x00007fff897c62cc +[NSException raise:format:] + 204
      3   Foundation                          0x00007fff87e71214 -[NSConcreteTask launchWithDictionary:] + 3167
      4   MyApp                               0x0000000100001c9a -[Receiver powerOnReceiver] + 218
      5   MyApp                               0x0000000100007053 -[AppDelegate powerOnReceiver:] + 67
      6   AppKit                              0x00007fff863733d0 -[NSApplication sendAction:to:from:] + 327
      7   AppKit                              0x00007fff8637324e -[NSControl sendAction:to:] + 86
      8   AppKit                              0x00007fff863bfd7d -[NSCell _sendActionFrom:] + 128
      9   AppKit                              0x00007fff863d9715 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2316
      10  AppKit                              0x00007fff863d8ae7 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 487
      11  AppKit                              0x00007fff863d81fd -[NSControl mouseDown:] + 706
      12  AppKit                              0x00007fff86359d08 -[NSWindow sendEvent:] + 11296
      13  AppKit                              0x00007fff862f8744 -[NSApplication sendEvent:] + 2021
      14  AppKit                              0x00007fff86148a29 -[NSApplication run] + 646
      15  AppKit                              0x00007fff86133803 NSApplicationMain + 940
      16  MyApp                               0x00000001000063e2 main + 34
      17  libdyld.dylib                       0x00007fff85ed05fd start + 1
  )
  </code></pre>
  
  <p>I think my path is correct here so I am not sure when I am getting the "Couldn't posix_spawn: error 13" message. Any thoughts would be greatly appreciated.</p>