title: C - popen not showing right output
body: <p>anyone know how I can fix this?</p>
  
  <pre><code>char bash_cmd[256] = "curl";
  char buffer[1000];
  FILE *pipe;
  int len; 
  
  pipe = popen(bash_cmd, "r");
  
  
  if (NULL == pipe) {
      perror("pipe");
      exit(1);
  } 
  fgets(buffer, sizeof(buffer), pipe);
  printf("OUTPUT: %s", buffer);
  pclose(pipe);
  </code></pre>
  
  <p>The above code snippit is returning the following:</p>
  
  <pre><code>OUTPUT: (�3B
  </code></pre>
  
  <p>instead of what it should be returning which is:</p>
  
  <pre><code>curl: try 'curl --help' or 'curl --manual' for more information
  </code></pre>
  
  <p>Something is wrong, I can't figure out what. When I replace "curl" with, say, "ls -la" it works fine, but for whatever reason only when I use curl, it doesn't properly save the output into buffer. What could I do to fix this?? thanks in advance</p>
  
  <p>Also, replacing "curl" with the full path to curl, (/usr/bin/curl) doesn't work either. ;(</p>