title: Run system command in R Shiny
body: <p>I have the below server function which takes two input files from the inputFile tab in the ui.</p>
  
  <pre><code>library(shiny)
  
  ui &lt;- fluidPage(
    fileInput("CF", label = "CF"),
    fileInput("ED", label = "ED"),
    actionButton("Run", "Run")
  )
  
  
  server &lt;- function(input, output, session) {
      cf_file &lt;- reactive({ 
          cfFile &lt;- input$CF
          return(cfFile$datapath)
      })
  
      ed_file &lt;- reactive({ 
          edFile &lt;- input$ED
          return(edFile$datapath)
      })
  
      table_content &lt;- eventReactive(input$Run, {
          req(input$ED$datapath)
          req(input$CF$datapath)
          file_ed &lt;- ed_file()
          file_cf &lt;- cf_file()
  
          ##the system command uses external program which takes input files (file_cf and file_ed) from fileInput. The command will look like:
          #/bin/qt con ed -i file_cf -p file_ed &gt; file_ed.db#
  
          system(paste("/bin/qt con ed -i", file_cf, "-p", file_ed, "&gt;", file_ed,".db" ))
      })
  }
  shinyApp(ui, server)
  </code></pre>
  
  <p>I have two issues here:</p>
  
  <p>1) The system command is not working here which gives the error:</p>
  
  <pre><code>qt: Error reading file '/var/folders/z0/kms9x7hd6hgdtbtk3kxnjcjxw2_l57/T//RtmpISFd3V/aac5eff9961beb644d8ec5e0/0.phe': End of file
  </code></pre>
  
  <p>The system command is taking the two input files and writing to an output file by adding ".db" to one of the inputFile. Could anyone point what is wrong in the above system command?</p>
  
  <p>I have followed the similar query at <code>https://community.rstudio.com/t/system-call-within-r-shiny/11405/3</code></p>
  
  <p>2) If the system command works, how can i render the output in the output file to table_content?</p>
  
  <p><strong>Tries &amp; Errors:</strong>
  I tried with <code>paste0()</code> but no luck, this time with a different error where it is not reading the input files file_cf and file_ed.</p>
  
  <pre><code> system(paste0("/bin/qt con ed -i ", file_cf, " -p ", file_ed, " &gt; ", file_ed,".db"))
  
  `Error accessing  file '/var/folders/z0/kms9x7hd6hgdtbtk3kxnjcjxw2_l57/T//RtmpjqfSir/6a3263bc18297e4b6567979e/0.cf -p/var/folders/z0/kms9x7hd6hgdtbtk3kxnjcjxw2_l57/T//RtmpjqfSir/02b964d65d0f0b1a9476a8be/0.ed': No such file or directory` 
  </code></pre>
  
  <p>Then using system2:</p>
  
  <pre><code>system2(paste0("/bin/qt con ed -i ",file_cf, " -p ", file_ed, " &gt; ", file_ed,".db" ))
  
  sh: /bin/qt con ed -i /var/folders/z0/kms9x7hd6hgdtbtk3kxnjcjxw2_l57/T//RtmpjqfSir/ebc57ae122e171f074281112/0.cf -p /var/folders/z0/kms9x7hd6hgdtbtk3kxnjcjxw2_l57/T//RtmpjqfSir/15a75f8fbe5992bd82ab8a22/0.ed &gt; /var/folders/z0/kms9x7hd6hgdtbtk3kxnjcjxw2_l57/T//RtmpjqfSir/15a75f8fbe5992bd82ab8a22/0.ed.db: No such file or directory
  Warning in system2(paste0("/bin/qt con ed -i ",  :
    error in running command
  </code></pre>
  
  <p>The above sh: command generated by R when run in shell outside R, using the tmp paths it works and can see the output files in the tmp path. But when it is run in R using the <code>system</code> and <code>paste0</code> it gives the above error.</p>