0

I am writing the script for analyzing data in which I am using the system2 function. I should hope, that my function is proper.

My function returns the problem:

Class 'try-error'  atomic [1:1] Error in system2(file.path(script.dir, "script1.sh"), c(matlab.dir,  :
  error in running command

  ..- attr(*, "condition")=List of 2
  .. ..- attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
NULL
Error occurred: Error in system2(file.path(script.dir, "script1.sh"), c(matlab.dir,  :
  error in running command

runPicnic <- function(sample.name, sample.type, sample.sex, sample.chip, script.dir, matlab.dir) {
  pre.res = system2(file.path(script.dir, 'script1.sh'), c(matlab.dir, sample.name, 'outdir', sample.type, sample.sex, sample.chip), stdout=TRUE, stderr=TRUE)
  post.res = system2(file.path(script.dir, 'script2.sh'), c(matlab.dir, sample.name, 'outdir'), stdout=TRUE, stderr=TRUE)
  return( list(pre.res, post.res) )
}

I am using this code for sending jobs to the queue on the cluster.

CrunchyTopping
  • 803
  • 7
  • 17
bwczech
  • 21
  • 4
  • Is that the true error message? I cannot find that error string in the R source ([google search](https://www.google.com/search?q=site%3Agithub.com%2Fwch%2Fr-source+"error+in+running+command")). (This doesn't mean it doesn't exist, just that I couldn't find it. Perhaps my search is too specific.) – r2evans Sep 04 '19 at 17:10
  • One thing I'd consider doing is wrapping paths with `shQuote` (in case there are inadvertently spaces or other specials in the path or filename). I don't know that that would trigger that error, but just a thought. – r2evans Sep 04 '19 at 17:13
  • Script with shQuote produced the same error: Class 'try-error' atomic [1:1] Error in system2(shQuote(file.path(picnic.dir, "run_init_hmm.sh")), c(matlab.dir, : error in running command ..- attr(*, "condition")=List of 2 .. ..- attr(*, "class")= chr [1:3] "simpleError" "error" "condition" NULL Error occurred: Error in system2(shQuote(file.path(picnic.dir, "run_init_hmm.sh")), c(matlab.dir, : error in running command – bwczech Sep 05 '19 at 17:01
  • Can you verify that `file.info(file.path(script.dir, "script1.sh"))` works without error or `NA`? I know it's an inane check (if you've already done it), but I don't know where to find that error message. – r2evans Sep 05 '19 at 18:44
  • I'm still stymied by a few things. Looking at the source for: [`system2`](https://github.com/wch/r-source/blob/23c3e20670a3e4f749894aba4a9327ac9ec405c3/src/library/base/R/windows/system.R#L113), [`file.path`](https://github.com/wch/r-source/blob/4986b0703b7676f73c9982d3d9bdd9ea794125d1/src/library/base/R/files.R#L90), and the internal [`do_filepath`](https://github.com/wch/r-source/blob/trunk/src/main/paste.c#L287), I can find no use of "error in running command". Further, the "try-error" you have is from `try(...)`, but neither your code nor any of the above functions directly call `try`. – r2evans Sep 05 '19 at 19:00

0 Answers0