Calling ssh with system in R shell eats subsequent

2019-07-19 15:39发布

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 .

标签: r vim emacs ess vim-r
1条回答
在下西门庆
2楼-- · 2019-07-19 16:17

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.

查看更多
登录 后发表回答