title: DBCA cannot be run as root
body: <p>I'm trying automate DBCA to create a new database. I'm using the box <a href="https://vagrantcloud.com/bseller/boxes/oracle-standard" rel="nofollow">bseller/oracle-standard</a> with Vagrant. </p>
  
  <p>provision.sh</p>
  
  <pre><code>#!/bin/bash
  echo 'Import environment variables'
  env=$( grep -ic "ORACLE_SID" /etc/profile )
  if [ ! $env -eq 1 ] ; then
      echo export ORACLE_SID=mydatabase &gt;&gt; /etc/profile
      echo export ORACLE_BASE=/u01/app/oracle &gt;&gt; /etc/profile
      echo export ORACLE_HOME=/u01/app/oracle/product/11.2/dbhome_1 &gt;&gt; /etc/profile
      source /etc/profile
      echo export PATH=$PATH:$ORACLE_HOME/bin &gt;&gt; /etc/profile
  fi
  
  echo "Connect with user ORACLE"
  sudo su -l oracle
  
  echo "Loading environment variables"
  source /etc/profile
  
  echo 'Create database mydatabase'
  if [ ! -d /u01/app/oracle/oradata/mydatabase ] ; then
      dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbName mydatabase -sysPassword mypassword -systemPassword mypassword -scriptDest /u01/app/oracle/oradata/mydatabase -characterSet WE8ISO8859P1
  fi
  </code></pre>
  
  <p>But this script doesn't worked: </p>
  
  <pre><code>$ sh provision.sh 
  Import environment variables
  Connect with user ORACLE
  Loading environment variables
  Create database mydatabase
  DBCA cannot be run as root.
  </code></pre>
  
  <p>Running all lines from provision.sh in command line. worked! </p>