在R shell中使用系统调用ssh可以执行后续命令 [英] Calling ssh with system in R shell eats subsequent commands
问题描述
我的工作流程是通过ESS包将emacs缓冲区中的命令从emacs发送到R会话。
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;
当我快速连续运行上面的三行(即将它们提交到R缓冲区)时, a结束时的值为0.当我慢慢运行它们时,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.
我只有通过系统运行ssh命令。在所有其他情况下,命令排队,并且都顺序运行。
I've only had this issue running an ssh command via system. In all other cases, the commands queue up and all run sequentially.
我的同事与他们的R / vim设置完全相同。但是我们在RStudio中没有同样的问题。
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 .
推荐答案
ssh
在系统期间放弃任何
命令。如果你逐行粘贴,那么在提交 stdin
) a = a + 1
之前, ssh
终止,因此它被传递给 R
而不是 ssh
。使用 system(ssh ..< / dev / null)
或 system(...,input =)
如果你不希望终端输入被子进程吃掉。
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.
这篇关于在R shell中使用系统调用ssh可以执行后续命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!