Zhiqiu Hu
2015-Dec-17 01:20 UTC
[R] How to bypass the pause in a program invoked using the "system" command
Dear Friends, I want to run a standalone console program (emBayesB) from R script on windows console. However, because the program asks user to press the enter key at each time after the analysis, the R code always stuck after invoking the emBayesB program with the "system()" function. For reproduce the issue, please save the following content as a "c:\RScript.R" file ##### start ######## AppPath="c:\\bin\\emBayesB_gs.exe" system(AppPath, wait = TRUE) ##### end ########## And copy the "emBayesB_gs.exe" file into "c:\\bin". The emBayesB program is freely accessible at (additional file 3) the follow website http://www.biomedcentral.com/1471-2105/11/529/additional Then, if you try to run the following command on windows console, you will see the issue. ##### start of console command ########## c:\\R\\bin\\Rscript.exe c:\\RScript.R ##### end of console command ########## FYI, if you submit the "c:\\R\\bin\\Rscript.exe c:\\RScript.R" use the "system()" function in R (tested with R-studio), you will not required to press the enter key to finish the run. Although, the emBayesB program was used in my case, but I suppose it is a general issue as you call any standalone program that require users to press key to exit, by run R scripts on windows console . Any suggestion is appreciated! Please let me know if you require more information about the issue. [[alternative HTML version deleted]]
Jeff Newmiller
2015-Dec-17 02:03 UTC
[R] How to bypass the pause in a program invoked using the "system" command
You cannot, in general. If the program is written to process the stdin input you might be able to feed it input that it expects, but many DOS/Windows console programs use BIOS to directly access the keyboard. -- Sent from my phone. Please excuse my brevity. On December 16, 2015 5:20:44 PM PST, Zhiqiu Hu <zhiqiu.hu at gmail.com> wrote:>Dear Friends, > >I want to run a standalone console program (emBayesB) from R script on >windows console. However, because the program asks user to press the >enter >key at each time after the analysis, the R code always stuck after >invoking >the emBayesB program with the "system()" function. > >For reproduce the issue, please save the following content as >a "c:\RScript.R" file >##### start ######## >AppPath="c:\\bin\\emBayesB_gs.exe" >system(AppPath, wait = TRUE) >##### end ########## > >And copy the "emBayesB_gs.exe" file into "c:\\bin". The emBayesB >program is >freely accessible at (additional file 3) the follow website >http://www.biomedcentral.com/1471-2105/11/529/additional > >Then, if you try to run the following command on windows console, you >will >see the issue. >##### start of console command ########## >c:\\R\\bin\\Rscript.exe c:\\RScript.R >##### end of console command ########## > >FYI, if you submit the "c:\\R\\bin\\Rscript.exe c:\\RScript.R" use the >"system()" function in R (tested with R-studio), you will not required >to >press the enter key to finish the run. > >Although, the emBayesB program was used in my case, but I suppose it is >a >general issue as you call any standalone program that require users >to press key to exit, by run R scripts on windows console . > >Any suggestion is appreciated! > >Please let me know if you require more information about the issue. > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code.[[alternative HTML version deleted]]