title: Unable to run shell script with full permissions (UNIX)
body: <p>I have a shell script that is created inside a php script (given full permissions).  When I try to run the shell script from Terminal, I get no errors, but the script does not run (none of the commands execute).  Although, once I copy the contents of the shell script, paste them into a new file in XCode, and overwrite the old shell script, it runs properly.</p>
  
  <p>Any suggestions?  I've been trying to figure this out for a very long time now with no progress.</p>
  
  <p>I'm assuming that there is an issue with writing the shell script from the php script since it works when written in XCode or a text editor.</p>
  
  <p>Here is the php script that writes the shell script:</p>
  
  <pre><code>&lt;code&gt;
      $filePath = "/Applications/MAMP/htdocs/php/Batch/modulator/Release23/Library/irShell.sh";
      $script = fopen($filePath, 'w+');
      chmod($filePath, 0777);
      fwrite($script,"#!/bin/sh");
      $irPath = "/Applications/MAMP/htdocs/php/Batch/modulator/Release23/Library"; //path to .ir files
      $modPath = "/Applications/MAMP/htdocs/php/Batch/modulator";
  
      if($dir = opendir($irPath)){        
          while(($file = readdir($dir)) !== false){
              $posA = strpos($file, ".IR");
              $posB = strpos($file, ".ir");
              $posC = strpos($file, ".Ir");
              if ($posA == true){
                  $fileName = trim($file, ".IR");
                  $noT = substr_replace($fileName, "", 0, 1);
                  echo "$noT\n";
                  fwrite($script, "\r" . $modPath . "/mod -o " . $irPath . "/codes/" . $noT . " " . $fileName . ".IR"); 
              }
              else if ($posB == true){
                  $fileName = trim($file, ".ir");
                  $noT = substr_replace($fileName, "", 0, 1);
                  echo "$noT\n";
                  fwrite($script, "\r" . $modPath . "/mod -o " . $irPath . "/codes/" . $noT . " " . $fileName . ".ir");
              }
              else if ($posC == true){
                  $fileName = trim($file, ".Ir");
                  $noT = substr_replace($fileName, "", 0, 1);
                  echo "$noT\n";
                  fwrite($script, "\r" . $modPath . "./mod -o " . $irPath . "/codes/" . $noT . " " . $fileName . ".Ir");
              }
          }
      }
  &lt;/code&gt;
  </code></pre>
  
  <p>And here's an example of a shell script that is generated by this php:</p>
  
  <p><code>
      #!/bin/sh</p>
  
  <pre><code>/Applications/MAMP/htdocs/php/Batch/modulator/mod -o /Applications/MAMP/htdocs/php/Batch/modulator/Release23/Library/codes/1294 T1294.ir
  /Applications/MAMP/htdocs/php/Batch/modulator/mod -o /Applications/MAMP/htdocs/php/Batch/modulator/Release23/Library/codes/1295 T1295.ir
  /Applications/MAMP/htdocs/php/Batch/modulator/mod -o /Applications/MAMP/htdocs/php/Batch/modulator/Release23/Library/codes/1296 T1296.ir
  </code></pre>
  
  <p></code></p>