bash - Capture Ingres createdb command in a variable -


not quite sure how need input createdb, ingres command, , pass variable in wrapper script , write log file.

#!/usr/bin/bash #  createdb_wrapper.scr #  log information 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}" ]     echo "please, enter fullname [enter]:"     read fname done  dbname=`bash createdb.scr | awk '{printf $1}'`  while [ -z "${desc}" ]     echo "please,enter brief description [enter]:"     read desc done   #checks directory exists, , creates if not if [ ! -d $default_dir ] ;then     echo "directory doesn't exit, created"     mkdir $default_dir fi  echo `date` '|' $dbname '|'  $fname '|'  $desc >> $default_dir/$default_log exit 

not quite sure you're trying do. trying database name createdb command? if so, can prompt in script , pass createdb e.g.:

read -p "please enter database name: " dbname createdb ${dbname} 

does help?

update:

i'm familiar ingres, have worked couple of decades or ;) you're trying put wrapper around createdb. had above work. create database default options. if want pass other options createdb you'll need prompt them principle's same.

the alternative check output of createdb database name. output looks 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 merely pass arguments of script through createdb using $* , grep output "completed successfully" can dbname , script have same options createdb itself.

the downside second approach if have quoted arguments can lose quotes e.g.

createdb.wrapper "-u$ingres" newdb 

becomes

createdb -u$ingres newdb 

and $ causes problem, why quoted in first place (though tend type \$ingres myself).

this may not issue you. have written scripts i've parsed args looking quotes re-add them , it's pain doable (maybe else has clever way it).

hth


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -