小编Ant*_*sse的帖子

sudo in non-interactive script

I have a script that executes three functions: A && B && C.

Function B needs to be run as a super-user, while A and C don't.

I have several solutions but neither of these are satisfying:

  1. sudo the entire script: sudo 'A && B && C'

    That seems like a bad idea to run A and C as super-user if it's not needed

  2. make the script interactive: A && sudo B && C

    I might have to type-in …

sudo shell-script

9
推荐指数
2
解决办法
2万
查看次数

标签 统计

shell-script ×1

sudo ×1