Calling ssh with system in R shell eats subsequent commands

橙三吉。 提交于 2019-12-11 02:18:15

问题


My workflow is to send commands from an emacs buffer to an R session in emacs via the ESS package.

a=0;
system("ssh remotehost ls")
a = a+1;

When I run the three lines above in rapid succession (i.e. submit them to the R buffer), the value of a at the end is 0. When I run them slowly, a is 1.

I've only had this issue running an ssh command via system. In all other cases, the commands queue up and all run sequentially.

My colleagues have the exact same issue with their R/vim setup. But we don't have the same issue in RStudio.

Any suggestions here would be great .


回答1:


ssh eats up any stdin during the system() command. If you paste it line by line then ssh terminates before you submit a=a+1 and thus it gets passed to R instead of ssh. Use system("ssh .. < /dev/null") or system(..., input="") if you don't want terminal input to be eaten by the subprocess.



来源:https://stackoverflow.com/questions/28838273/calling-ssh-with-system-in-r-shell-eats-subsequent-commands

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!