[R] Question about escapes character in args parameter of the system2 function.

Xiaobo Gu guxiaobo1982 at gmail.com
Wed Dec 14 11:12:01 CET 2011


I am trying to use the system2 function to execute external
applications(actually it is psql) inside R 2.14.0 on X64 Windows, but
the psql command has escape character inside it's full command line,
can you help to figure out the correct parameters for the system2

The working command is :

psql -h -U gpadmin -w -d miner_demo -c"\copy demo.store
to 'd:\store.csv' with csv header"

and my R code is:
  psql <- "psql.exe"
  gphost <- ""
  gpuser <- "gpadmin"
  gpdb <- "miner_demo"

  copycmd <- "-c \"\\copy demo.store to 'd:\\store.csv' with csv header\""
  args <- c("-h", gphost, "-U", gpuser, "-w", "-d", gpdb, copycmd )
  system2(psql, args)

And the return value of system2 function is 127.


Xiaobo Gu

More information about the R-help mailing list