title: Script to automate kadmin principal
body: <p>I am trying to write a script to automate kerberos principal and but the script is not working. Not sure what i am missing. Below is the code:</p>
  
  <pre><code>#!/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
  </code></pre>
  
  <hr>
  
  <p>Also tried writing this way:</p>
  
  <pre><code>################### create principal #############
  pass="principal_password"
  echo "password" | kinit adminuser/admin
  printf "%b" "password" | kadmin
  printf "%b" "addprinc principal_name\n$pass\n$pass" 
  </code></pre>
  
  <p>But its not working in script. </p>