我正在尝试使用shell命令从R运行简单的外部应用程序。
shell('"C:\\Program Files\\SomeApp\\bin\\Release\\SomeApp.exe" "C:\\Users\\SomeUser\\R_Scripts\\RProjects\\Rprojects\\" "1" "yes"')
如果我从命令行运行部分括号,它可以很好地工作。但是如果我通过R的shell命令运行它会抛出一个错误:
'C:\Program' is not recognized as an internal or external command, operable program or batch file.
Warning messages:
1: running command 'C:\Windows\system32\cmd.exe /c "C:\Program Files\SomeApp\bin\Release\SomeApp.exe" "C:\Users\SomeUser\R_Scripts\RProjects\Rprojects\" "1" "yes"' had status 1
2: In shell("\"C:\\Program Files\\SomeApp\\bin\\Release\\SomeApp.exe\" \"C:\\Users\\SomeUser\\R_Scripts\\RProjects\\Rprojects\\\" \"1\" \"yes\"") :
'"C:\Program Files\SomeApp\bin\Release\SomeApp.exe" "C:\Users\SomeUser\R_Scripts\RProjects\Rprojects\" "1" "yes"' execution failed with error code 1
还有其他人面临同样的问题吗?
空格分隔的文本应该是双引号。这适用于R的shell命令。
shell('C:\\"Program Files"\\SomeApp\\bin\\Release\\SomeApp.exe "C:\\Users\\SomeUser\\R_Scripts\\RProjects\\Rprojects\\" "1" "yes"')