title: Bash - Python - Mysql - Creating a user
body: <p>I have almost fully automated a freeradius/mysql/gui front end configuration in Linux, but I am missing one last, important step to ensure full automation. The issue I need to overcome is as follows:</p>
  <p>In the bash script or in python (which would have to be called from the bash script) I need to ask the user for the password they would like to use for an SQL user. However, using normal bash and sql is not possible due to them being separate shells. So, normally I would use the following to read in the user response:</p>
  <pre><code>read -p &quot;Please enter the password you require for user radius in sql: &quot; password
  </code></pre>
  <p>Then in sql you would think you could use the following:</p>
  <pre><code>CREATE USER 'radius'@'%' IDENTIFIED BY '&quot;$password&quot;';
  </code></pre>
  <p>However, as I mentioned, they are separate shells so sql does not know about the variable &quot;password&quot; and so it cannot use it. The same goes for if I try and use &quot;read -p&quot; within the &quot;mysql &lt;&lt; _EOT&quot; section, sql does not see this command as a valid sql command (which it isn't).</p>
  <p>So, I need to use python, or some code, that can either read the bash input and inject into sql or read in its own user input and inject into sql.</p>
  <p>Problem is, I know very little (meaning nothing) about Python, so hoping someone can point me in the right direction here.</p>