[PowerShell] 检查当前执行脚本的用户是不是root用户 →→→→→进入此内容的聊天室

来自 , 2020-08-28, 写在 PowerShell, 查看 126 次.
URL http://www.code666.cn/view/b440369b
  1. #1 这个比较麻烦一点
  2. id | grep "uid=0(" >/dev/null
  3. if [ $? != "0" ]; then
  4. uname -a | grep -i CYGWIN >/dev/null
  5. if [ $? != "0" ]; then
  6. echo "ERROR: The Webmin install script must be run as root"
  7. echo ""
  8. exit 1
  9. fi
  10. fi
  11. #2 相对简单快捷一些
  12. if [ $(id -u) != "0" ]; then
  13. echo "Error: You must be root to run this script, please use root to run this script"
  14. exit 1
  15. fi
  16.  
  17. //shell/1265

回复 "检查当前执行脚本的用户是不是root用户"

这儿你可以回复上面这条便签

captcha