Not quite sure how to do this but I need to get the input from createdb, which is an Ingres command, and pass it to a variable in the wrapper script and then write to log file.
#!/usr/bin/bash
# createdb_wrapper.scr
# Log information about user of createdb.scr
#Install=`echo $II_SYSTEM`
#Default_Dir=$Install/ingres/DBA
#Database=`echo ingprenv II_DATABASE`
Default_Dir=/export/home/cwatts/test
Default_Log=DB.Audit
while [ -z "${fname}" ]
do
echo "Please, enter your Fullname [ENTER]:"
read fname
done
dbname=`bash createDB.scr | awk '{printf $1}'`
while [ -z "${desc}" ]
do
echo "Please,enter a brief Description [ENTER]:"
read desc
done
#Checks the directory exists, and creates if not
if [ ! -d $Default_Dir ] ;then
echo "directory doesn't exit, it will be created"
mkdir $Default_Dir
fi
echo `date` '|' $dbname '|' $fname '|' $desc >> $Default_Dir/$Default_Log
exit
Not quite sure what you're trying to do. Are you trying to get the database name from the createdb command? If so, you can just prompt for it in your script and then pass it to createdb yourself e.g.:
read -p "Please enter a database name: " dbname
createdb ${dbname}
Does that help?
UPDATE:
I'm familiar with Ingres, have worked with it for a couple of decades or so ;) So you're trying to put a wrapper around createdb. So something like what I had above would work. However that would create the database with the default options. If you want to pass the other options to createdb you'll need to prompt for them also but the principle's the same.
The alternative is to check the output of createdb to get the database name. That output looks like this:
$ createdb pauldb
Creating database 'pauldb' . . .
Creating DBMS System Catalogs . . .
Modifying DBMS System Catalogs . . .
Creating Standard Catalog Interface . . .
Creating Front-end System Catalogs . . .
Creation of database 'pauldb' completed successfully.
So if you were to merely pass the arguments of your script through to createdb using $* and then grep the output for "completed successfully" then you can get the dbname from that and your script will have all the same options as createdb itself.
The only downside to the second approach is that if you have any quoted arguments then you can lose the quotes e.g.
createdb.wrapper "-u$ingres" newdb
becomes
createdb -u$ingres newdb
and that $ causes a problem, which is why you quoted it in the first place (though I tend to type \$ingres myself).
This may not be an issue for you. I have written scripts where I've parsed the args looking for quotes to re-add them and it's a pain but doable (maybe someone else has a clever way to do it).
HTH