Shell Script Question

Link to this post 18 Oct 09

Hi all
I want u to help answer this question
( A shell script should be named and its purpose is to create a new database. It accepts two arguments, the first is SCHEMA_NAME and the second is a DATABASE_NAME. For instance, below is an example invocation of the script and response.
$ persons tutors
The name of the database and the schema it uses should be appended to the databases.txt file.
Below is an example databases.txt file:
tutors persons
student persons
nina_12345_grades grades
intel company
If either the SCHEMA_NAME does not exist or the DATABASE_NAME already exists, then you the command prints an appropriate error message and exit. If the SCHEMA_NAME exists and the DATABASE_NAME is not already used, then the script should append the information to the end of the databases.txt file, create a new empty database file of the form DATABASE_NAME.db, and print a message that the database has been created.

thank you.

Link to this post 19 Oct 09

And the question is?

Link to this post 19 Oct 09

Are you building your own text file based database or will this script be used with a database system like mysql or postgresql?

Also can you please post the contents of your script so we can review your progress and recommend modifications?

Link to this post 21 Oct 09

here's a possible script skeleton. Copy the code below and paste into
a script file. Fill in with your commands (database creation, etc.).


cat <<END
USAGE: $0 schema_name database_name
provide description here
return 1
#enter the commands to create the database
if [ $? -eq 0 ]; then
echo "created database $2 with schema $1"
echo "$2 $1" >> $LOG
return 0
echo "your error message here"
return 1
#check number of arguments entered
if [ $# -ne 2 ]; then
exit $?
create_database $1 $2

You should probably use absolute path for the log file, eg


That way you could invoke the script from anywhere.

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Linux Training / Board