How do you prompt for a sudo password using Ruby?

前端 未结 4 2019
栀梦
栀梦 2020-12-19 06:52

Often I find myself needing to write scripts that have to execute some portions as a normal user and other portions as a super user. I am aware of one similar question on SO

4条回答
  •  难免孤独
    2020-12-19 07:15

    I do not know if this is what you want or need, but have you tried sudo -A (search the web or the man page for SUDO_ASKPASS which might have a value like /usr/lib/openssh/gnome-ssh-askpass or similar)? This is what I use when I need to present a graphical password dialogue to users in GUI environments.

    Sorry if this is the wrong answer, maybe you really want to remain on the console.

提交回复
热议问题