如何執行通常需要用戶交互的系統命令?例如,我想運行:執行需要用戶輸入的終端命令
system("ssh-keygen")
在終端提示,它看起來像這樣:
iMac-2:~ admin$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/admin/.ssh/id_rsa):
在RStudio,該命令引起應用程序掛起。
我試過選項wait=FALSE
和invisible=FALSE
,但他們似乎沒有幫助。
R: Using wait=FALSE in system() with multiline commands
`system()` interactive .exe/binary from R/Rgui
'system'函數有一個'輸入='參數。您可以嘗試將用戶輸入編碼到此參數中。 – mt1022