2

I have a perl script (SFDRv166.pl, available here http://bit.ly/1DGmUTL) that I run successfully from the command line using:

perl SFDRv166.pl -assoc input.txt -SFDR -out test

I now need to run this program as part of an R script, and have tried implementing it as follows:

arg1 <- shQuote("-assoc input.txt")
arg2 <- shQuote("-SFDR")
arg3 <- shQuote("-out test")

system("perl SFDRv166.pl arg1 arg2 arg3")

However, I get an ERROR: cannot find ! message generated I believe because the arguments are not getting passed to the perl script (output says no input or output file specified, and no output is created).

I can see from reading the documentation for system() that arguments with spaces require special handling, which is why I have tried to use shQuote(). Not sure what else may be wrong with my approach?

2
  • Use paste: system(paste("perl","SFDRv166.pl",arg1,arg2,arg3)) Commented Apr 7, 2015 at 12:18
  • Look at the source for xls2sep in the gdata package. It calls perl with arguments. Commented Apr 7, 2015 at 12:28

1 Answer 1

2

Try this:

arg1 <- "-assoc input.txt"
arg2 <- "-SFDR"
arg3 <- "-out test"
cmd <- paste("perl", "SFDRv166.pl", arg1, arg2, arg3)
system(cmd)

Now you don't need shQuate.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.