title: Can I interact with a windows console program with R
body: <p><strong>EDIT: I am working on solving this problem through the Genepop settings file but I am also interested in the general issue of this problem, can I interact with windows console programs with R?</strong> </p>
  
  <p>I would like to automate using a genetic analysis program, <a href="http://genepop.curtin.edu.au/" rel="nofollow">Genepop</a>, by issueing commands to the windows console from R.  Opening the program is trivial, however I don't know if it is possible to enter the next consecutive lines after opening. The first thing I need to do is enter a text file. If I could pass any small simple character string I would know if I could get a message that would tell me I could it working.   </p>
  
  <pre><code>&gt; shell(".../Genepop.exe")
  Genepop version 4.2.2
  
  Unable to open file genepop.txt
  Unable to open file genepop.txt
  Genepop version 4.2.2
  
  
  Name of the data file ? (press ENTER to quit)
  &gt;
  </code></pre>
  
  <p>It will quit out if I just open the program without asking for the next line in R. Pretty much what I expected.  I then tried using a semicolon like it mentions in shell help file for the command arguement. </p>
  
  <blockquote>
    <p>... so command
    can be anything the shell regards as executable, including shell
    scripts, and it can contain multiple commands separated by ;.</p>
  </blockquote>
  
  <p>But this didn't seem to help. </p>
  
  <pre><code>&gt;first_line &lt;- paste(genepopDir, genepopFile, sep = "/")
  &gt;data_file &lt;- "genepopInput"
  &gt;test &lt;- paste(first_line,data_file, sep = ";")
  &gt;shell(test)
  Genepop version 4.2.2
  
  Unable to open file genepop.txt
  Unable to open file genepop.txt
  
  Reading settings file cmdline.txt...
  Genepop version 4.2.2
  
  
  Name of the data file ? (press ENTER to quit)
  </code></pre>
  
  <p>So maybe I can use a character vector? There is some documentation under the input argument that is hinting to me that is what I should try. </p>
  
  <pre><code>&gt; test &lt;- c(first_line, data_file)
  &gt; shell(test)
  Error in system(command, as.integer(flag), f, stdout, stderr) : 
    character string expected as first argument
  </code></pre>
  
  <p>I'm using R 3.1, windows 7, x86.</p>