开发者

How to run system() command in R script

I have a local server insalled on my system and have to start that from within my R function.

here is how I start it:

cmd<-"sh start-server.sh"  
system(cmd, wait=FALSE)

I have to perform computations after starting the server. Basically my function has to start the ser开发者_高级运维ver and proceeds with further steps. The server starts but the further steps of the program are not executed.The cursor keeps waiting after the server is started.

Please suggest how to go about this.


My problem is finally solved. I had to add Sys.sleep() and it runs after waiting for few seconds. Thank you for help.


You need to determine whether or not the problem is with the server script or with R's execution of the script. Try:

  1. Running sh start-server.sh directly from a command prompt and seeing what happens.

  2. Running something simple via R's system function, e.g., system("ls", wait = FALSE).


By default, system waits for the executed command to terminate before returning. Add wait=FALSE if you want it to return immediately.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜