在shell脚本中需要用root用的来执行指令:
sudo 自动输入密码
echo "password" | sudo -S netstat -tlnp
-S
The -S (stdin) option causes sudo to read the password from the standard input instead of the terminal device.
sudo 自动输入密码
echo "password" | sudo -S netstat -tlnp
-S
The -S (stdin) option causes sudo to read the password from the standard input instead of the terminal device.
本文介绍如何在Shell脚本中使用sudo命令自动输入密码执行特定任务,通过使用echo配合sudo -S选项实现自动化操作。
3万+

被折叠的 条评论
为什么被折叠?



