0
我爲Objective-C called NMSSH使用了美妙的libssh包裝。我能夠建立連接,發送命令等,但我遇到了一些麻煩。每當我送提升的命令,如「sudo..something」,我得到我的響應對象以下錯誤:爲NMSSH庫提供「sudo」命令的密碼
Error: Error Domain=NMSSH Code=0 "sudo: no tty present and no askpass program specified
" UserInfo=0x145a65e0 {command=sudo apachectl start, NSLocalizedDescription=sudo: no tty present and no askpass program specified
, NSLocalizedFailureReason=54}
我怎麼能告訴程序什麼的密碼是什麼?
我upvoted這個答案,因爲它可以工作,但是,取決於你的分佈,它不。例如,使用NMSSH在CentOS機器上執行以下操作將返回相同的錯誤「echo | sudo -S ls /etc/init.d/」,但它可以在Ubuntu上使用。有關更多詳情,請參閱此文章http://unix.stackexchange.com/questions/122616/why-do-i-need-a-tty-to-run-sudo-if-i-can-sudo-without-a-密碼 –
AndrewSmiley