[英]Bash script to switch to root user with password (no additional libraries like expect can be used)
su
Enter Password: abcd
I need to be able to do the above process through a shell script.我需要能够通过 shell 脚本完成上述过程。 The issue is that it needs to be done with only the basic set of libraries that are available.
问题是它只需要使用可用的基本库集来完成。 No additional libraries can be used (eg except).
不能使用额外的库(例如,除外)。 Kindly do not suggest the usage of "sudo" or other things, this is the exact thing I need to do.
请不要建议使用“sudo”或其他东西,这正是我需要做的事情。 I have tried the following:
我尝试了以下方法:
echo "abcd" | su
But it still ends up asking for the password again.但它最终仍然再次要求输入密码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.