Why is createdb-postgres.sh/.bat returning a help message ?

Document ID : KB000017118
Last Modified Date : 14/02/2018
Show Technical Document Details
Introduction:

   When running the createdb-postgres.sh/.bat, it is not always clear why you get a message like

 Arguments required <dbserverhost> <dbinstalldir> <dbname> <dbserviceuser> <dbservicepwd> <dbadminuser> <dbadminpwd> <dbport <optional>>

 dbinstalldir: complete path where the database is installed excluding the bin dir. 

 eg: /opt/database/postgres/8.3-community 

Question:

  I am running createdb-postgres.sh/.bat with these arguments

  $ ./createdb-postgres.sh 127.0.0.1 /opt/CA/PostgreSQ/data/base cemdb admin topsecret 

  The install stops and returns 

     Arguments required <dbserverhost> <dbinstalldir> <dbname> <dbserviceuser> <dbservicepwd> <dbadminuser> <dbadminpwd> <dbport <optional>>

     dbinstalldir: complete path where the database is installed excluding the bin dir.
     eg:/opt/database/postgres/8.3-community

Environment:
This was found on APM 10.5.2 but can happen in any release.
Answer:

   The reason is typically that the number of arguments is less than expected.

 The code for this in the UNIX shell script is 

if [ $# -lt 7 ]; then

  echo "Arguments required <dbserverhost> <dbinstalldir> <dbname> <dbserviceuser> <dbservicepwd> <dbadminuser> <dbadminpwd> <dbport <optional>>"

  echo "dbinstalldir: complete path where the database is installed excluding the bin dir. "

  echo "eg: /opt/database/postgres/8.3-community "

  exit

fi

    In Windows, the code snippet looks like: 

IF "%7"=="" (

  echo ERROR: Insufficient arguments

  echo "Required arguments [dbserverhost] [dbinstalldir] [dbserviceuser] [dbservicepwd] [dbname] [dbuser] [dbpassword] [dbport <optional>]"

  goto end

)

 

 

In the above case, you have five required arguments instead of seven. (Such as missing <dbservicepwd> <dbadminuser>) 

Simply re-do the install with all the arguments with valid values and you should be successful.