title: Running a C program from php
body: <p>I have a C program I have compiled to a exe called crunch.</p>
  
  <p>It takes a string and returns a hash string. It has worked for a long time but I just needed to make a small change to it. It works perfectly in terminal as such:</p>
  
  <pre><code>./crunch url-string/with-file.jpg
  </code></pre>
  
  <p>Spits out a nice hash string. In my php I have been executing it as such:</p>
  
  <pre><code>$crunch = '~/domains/somewhere.net/html/api/crunch';
          $code = `$crunch $code`;
          $code = mysql_real_escape_string(trim($code));
  </code></pre>
  
  <p>$code is initially a string which is an URL. It has been returning a hash but not any more.</p>
  
  <p>I have recompiled the C a few times. Just don't get it, I have tried php exec() , passthru().</p>
  
  <p>FIXED:</p>
  
  <p>The issue was the difference between my Mac Unix distros and the linux server. The fix was to log into my server and compile the .c file there.</p>
  
  <p>Bobs your Uncle, works again.</p>
  
  <p>Thanks peeps, I did check everyones advice. Sometimes ruling out possible breaks helps focus on the issue. Virtual beers(or sparkling water) all around!</p>