我正在尝试编写一个脚本来自动化kerberos主体,但脚本无效。不知道我错过了什么。以下是代码:
#!/bin/bash
read -p "Please enter space-delimited list of principal to create: " NEW_Principal
clear
echo "password" | kinit adminuser/admin ; echo "password" | kadmin
for i in $NEW_ORGS
do
addprinc ${i}
${i}
echo ""
done
也尝试这样写:
################### create principal #############
pass="principal_password"
echo "password" | kinit adminuser/admin
printf "%b" "password" | kadmin
printf "%b" "addprinc principal_name\n$pass\n$pass"
但是它不能用于脚本。
答案 0 :(得分:3)
我做到了。我所要做的就是将命令作为字符串传递。这是答案:
echo -e "${i}\n${i}" | kadmin -w "$krb_pass" -q "addprinc