I could not use R commands on Mac OS X, so, like with GRASS, I decided to analyze the Python scripts and the sextante log to understand what happens<br><br>This time, no error in the log but no results either, no resulting shapefile in /Users/martinlaloux/sextante/tempdata. The temporary script /Users/martinlaloux/sextante/<b>sextante_script.r</b> has been created  so the problem is again in the parameters of the Python module subprocess in <b>Rutils.py</b> (line 58):<br>

<br><div style="margin-left:40px">command = ["R", "CMD","BATCH", "--vanilla", RUtils.getRScriptFilename(), RUtils.getConsoleOutputFilename()]<br>proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE,stderr=subprocess.STDOUT, universal_newlines=True)<br>

</div><br>Usually when I want to run an R script in Python, I use the command (see "QGIS: run Python scripts from the Python Console  or with Script Runner (without creating an extension)" (in french  <a href="http://www.portailsig.org/content/qgis-lancer-des-scripts-python-ou-des-commandes-shell-depuis-la-console-python-ou-avec-scrip">QGIS : lancer des scripts Python ou des commandes Shell depuis la Console Python ou avec Script Runner </a>):<a href="http://www.portailsig.org/content/qgis-lancer-des-scripts-python-ou-des-commandes-shell-depuis-la-console-python-ou-avec-scrip"></a><br>

  <br><div style="margin-left:40px">subprocess.Popen(['Rscript','sextante_script.r'],stdout=subprocess.PIPE)) -> <b>works</b><br></div><br><u>But what about the solution of the script ?</u><br>If I try to run the procedure directly in the Python shell (with sextante_script.r obtained by the script):<br>

<br>>>> import subprocess<br>>>> doc=subprocess.Popen(['R', 'CMD', 'BATCH', 'sextante_script.r'],stdout=subprocess.PIPE) -> <b>works</b><br>>>> doc=subprocess.Popen(['R', 'CMD', 'BATCH', 'sextante_script.r'],stdout=subprocess.PIPE, stdin=subprocess.PIPE,stderr=subprocess.STDOUT, universal_newlines=True) -> <b>works</b><br>

>>> doc=subprocess.Popen(['R', 'CMD', 'BATCH', 'sextante_script.r'], shell= True, stdout=subprocess.PIPE, stdin=subprocess.PIPE,stderr=subprocess.STDOUT, universal_newlines=True) -> <b>no result </b><br>

<br><u>Why ? </u><br><b><br>The problem is shell= True</b> <b>with Unix systems. </b><span id="result_box" class="" lang="en"><span class="hps">I have</span> <span class="hps">already encountered</span> <span class="hps">this problem</span> <span class="hps">many times</span> <span class="hps">in</span> <span class="hps">my work<br>

</span></span><b></b><span id="result_box" class="" lang="en"><span class="hps">A good explanation</span> <span class="hps">is given</span></span> in the <a href="http://stackoverflow.com">stackoverflow.com</a> question: <a href="http://stackoverflow.com/questions/9095733/getting-output-from-python-script-in-python-tests/9096104#9096104">Getting output from Python script in Python tests</a><br>

<br><b> "If you're using shell=True, don't pass the program and its arguments as a list</b>"  <b>but whith a string</b><br><br>- replacing the line 58 of Rutil.py by<br><br>     <b>command = "R CMD BATCH --vanilla " + RUtils.getRScriptFilename() + " "+ RUtils.getConsoleOutputFilename()</b><br>

     proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE,stderr=subprocess.STDOUT, universal_newlines=True)<br><b><br>works because the result of command is a string</b><br><br>- or <br>

      command = ["R", "CMD","BATCH", "--vanilla", RUtils.getRScriptFilename(), RUtils.getConsoleOutputFilename()]<br>      <b>proc = subprocess.Popen(command, stdout=subprocess.PIPE,  stdin=subprocess.PIPE,stderr=subprocess.STDOUT, universal_newlines=True)</b><br>

<br><b>works also because shell=false.</b><br><br>The complete explanation is (from the question of stackoverflow): <br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">

<b>On Unix, with <em>shell=True</em>: If <em>args</em> is a string, it specifies the
  command string to execute through the shell. This means that the
  string must be formatted exactly as it would be when typed at the
  shell prompt. This includes, for example, quoting or backslash
  escaping filenames with spaces in them. If <em>args</em> is a sequence, the
  first item specifies the command string, and any additional items will
  be treated as additional arguments to the shell itself.</b><br><br></blockquote><span id="result_box" class="" lang="en"><span class="hps">I hope</span> <span class="hps">you understand</span> <span class="hps">why</span> <span class="hps">the original script</span> <span class="hps">does not work</span> <span class="hps">on</span> <span class="hps">Mac</span> <span class="hps">OS</span> <span class="hps">X</span><span class="">, a</span> <span class="hps">Unix system. </span></span><span id="result_box" class="" lang="en"><span class="hps">By modifying</span> <span class="hps">line 58</span><span>,</span> <span class="hps"></span></span><span id="result_box" class="" lang="en"><span class="hps">no</span> <span class="hps">more</span> <span class="hps">problem</span></span><span id="result_box" class="" lang="en"><span class="hps"><br>

</span></span>