0

I am trying to execute below console commands from RStudio to move to Root from myuser Rstudio.

cmd <- sprintf("sudo su -")
system(cmd)

While doing I am getting this reponse: "sudo: no tty present and no askpass program specified"

while from putty I am able to execute "sudo su -"

Can anyone please suggest the way to execute above console Commands from R/RStudio and get resolved the error.

string
  • 787
  • 10
  • 39
  • Because R and RStudio are not designed/setup to execute *interactive* shell commands. – r2evans Apr 13 '17 at 13:34
  • @r2evans Thanks for the response. So, Is there no way we can trigger interactive shell commands from R. Needed for a dynamic Shiny App – string Apr 13 '17 at 13:59
  • Interactive pipes are not really well supported in R. There have been discussions in the past, and unix-based R may be able to [hack it](http://stackoverflow.com/a/5561188/3358272) (caveat emptor: old, untested), but I have not found anything (and I've been looking) that supports starting a process and interacting with it (easily). (Are you really trying to provide access to an interactive *shell* (bash) from within a shiny app? Good luck ...) – r2evans Apr 13 '17 at 14:04
  • Thanks for the information. Yes, Trying to change the permission of files from root through R.Have found this: http://stackoverflow.com/questions/34927257/is-there-an-r-function-to-change-file-ownership - About gksudo – string Apr 13 '17 at 14:29
  • I cannot stress this too strongly: caution! A lot of things can go wrong by automating the use of passwordless `sudo`. Really think about what you are trying to accomplish here. I suggest you would be better served by describing what is driving you to want to do that and solicit alternatives that don't punch a gaping whole in security :-) – r2evans Apr 13 '17 at 20:17

0 Answers0