1

我正在尝试为 R 编写一个可与​​ Rstudio 一起使用的 getpass 函数。我尝试过使用 getpass C 函数(*nix,带有 Rcpp)以及使用 rPython 从 python 中使用 getpass,两者似乎都可以在终端中工作,但是会导致 Rstudio 提示在输入密码并点击返回后冻结.

python的get pass的输出是,

/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/getpass.py:83: GetPassWarning: Can not control echo on the terminal.
passwd = fallback_getpass(prompt, stream)
Warning: Password input may be echoed.

并使用getpass(const char *prompt);我只是得到永远不会返回到 R 提示的密码提示。

根据要求,一些在终端中有效但在 R-studio 中无效的代码片段,

library(rPython)
python.exec("import getpass")
pass = python.get("getpass.getpass()")

Rcpp/内联代码,

library(inline)
str = 'std::string pass = (const char *) getpass("Password: ");\n;\n return(wrap(pass));'
testfun = cxxfunction(signature(),body=str,plugin="Rcpp")
testfun()

请注意,我在 Mac 上,但在其他具有getpass().

有什么线索吗?

4

0 回答 0