我有以下脚本,它应与sudo一起运行,但是命令(git命令)的第一个需要以用户“ ubuntu”的身份运行
sudo -u ubuntu "git -C linux/build-repo pull"
sudo -u ubuntu "git -C android/build-repo pull"
uoa_image=$(sh linux/build-repo/make.sh | sed -n '1 p')
echo $uoa_image
但是,当使用sudo运行此命令时,前两个命令将失败,并且运行时的make.sh脚本会抱怨它没有root用户
第一行给出了错误:
sudo: git -C linux/build-repo pull: command not found
sudo: git -C android/build-repo pull: command not found
一种选择:
以sudo-to-root身份运行整个脚本,并将前两行更改为改为使用su
:
su -c "git -C linux/build-repo pull" ubuntu
su -c "git -C android/build-repo pull" ubuntu
...
第二种选择:
设置root的PATH,以便它可以找到git
命令。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句