不知道有没有(shell)
Tofloor
poster avatar
cy844757727
deepin
2017-11-02 21:37
Author
本帖最后由 cy844757727 于 2017-11-2 13:38 编辑

问题描述:我有一个批处理脚本,我希望能后台运行它,但脚本里有 sudo 需要权限,如果不前台终端运行就无法输入了,后台运行就一卡在这一步。我查看了sudo的手册里面有这么一个选项
  1. -A, --askpass
  2. Normally, if sudo requires a password, it will read it from the
  3.                  user's terminal.  If the -A (askpass) option is specified, a
  4.                  (possibly graphical) helper program is executed to read the
  5.                  user's password and output the password to the standard output.
  6.                  If the SUDO_ASKPASS environment variable is set, it specifies
  7.                  the path to the helper program.  Otherwise, if sudo.conf(5) con‐
  8.                  tains a line specifying the askpass program, that value will be
  9.                  used.  For example:

  10.                      # Path to askpass helper program
  11.                      Path askpass /usr/X11R6/bin/ssh-askpass

  12.                  If no askpass program is available, sudo will exit with an
  13.                  error.
Copy the Code



意思就是可以指定一个图形化的权限申请界面的程序,不知道deepin里有没有,如果有在哪???能让shell后台,当需要sudo时弹出提权申请窗口
https://bbs.deepin.org/user/48640
Copy the Code


Reply Favorite View the author
All Replies
avatar
woodelf
deepin
2017-11-02 22:11
#1
用sudo -S就可以了啊,直接通过管道从标准输入读取密码,例如,echo "123456"|sudo -S xxxx。
图形的授权提示是另一种机制,通过polkit+gksudo实现的。
Reply View the author
avatar
cy844757727
deepin
2017-11-03 00:41
#2
https://bbs.deepin.org/post/147603
用sudo -S就可以了啊,直接通过管道从标准输入读取密码,例如,echo "123456"|sudo -S xxxx。
图形的授权提 ...

搞定
Reply View the author