1

I tried to save the results from a System call of an environmental variable in R, following this: store output of system command into a variable in r.

(Note: I am aware i can use: Sys.getenv(). The call to an environmental variable is just a simplified example to Keep the question "minimal").

OS is Windows 10.

This works:

> system(command = "SET", intern = FALSE)
[1] 127

This does not:

> system(command = "SET", intern = TRUE)
Error in system(command = "SET", intern = TRUE) : 'SET' not found

This works again:

> system(command = "ls", intern = TRUE)
 [1] "DESCRIPTION"                                          
 [2] "NAMESPACE" 
 ...

Attempts from the suggestions in the comments:

First:

> system(command='echo $SET', intern=TRUE)
[1] "$SET"

Second:

> system(command = "SET", intern = TRUE, ignore.stdout = TRUE)
character(0)
attr(,"status")
[1] 127
Warning messages:
1: In system(command = "SET", intern = TRUE, ignore.stdout = TRUE) :
  'SET' not found
2: In system(command = "SET", intern = TRUE, ignore.stdout = TRUE) :
  running command 'SET' had status 127
Tlatwork
  • 1,445
  • 12
  • 35
  • What OS are you on? Did you try `system(command='echo $SET', intern=TRUE)`? – rbatt Mar 10 '20 at 10:26
  • Running `system(command = "SET", intern = TRUE, ignore.stdout = TRUE)` might be elucidating. – Roland Mar 10 '20 at 10:27
  • thanks a lot for the fast replies! OS is Windows 10, i added this info + the Outputs from your Code suggestions in my question. – Tlatwork Mar 10 '20 at 10:35
  • 1
    See the documentation in `help("system")`, the return value of 127 indicates that the command could not be run. – Roland Mar 10 '20 at 11:14

0 Answers0