Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

shell - R system functions always returns error 127

I need to execute an external tool from R and process errors (if any) occurred in that tool. I know 3 functions to do something familiar with my task:

shell, system and system2.

Trying to test those, I see that command

shell("notepad") 

opens notepad. As far as I know shell doesn't allow to check errors (there's no interface to look into stderr).

When I call

system("notepad")

or

system2("notepad") 

R freezes trying to make those commands.

Calling

system("start notepad") 

or

system2("start notepad") 

returns warning

Warning message:
running command '"start notepad"' had status 127 
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Adapting @DavidTseng's answer (sorry for not having enough reputation to upvote it)...

system("cmd.exe", input = "notepad")

worked for me in Windows.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...