السلام عليكم
ارجو مساعدتي في كتابة هذه البرامج
ولكم الاجر والثواب
بالسرعة القصوى
بريدي هو :
akeel101@hotmail.com
moh_akeel@yahoo.com
Exercise: write three shell scripts used to setup and initialize a simple text database (single-table database):

1- Your first shell script should be named new_schema.sh. Its purpose is to create a new schema. It accepts as arguments a SCHEMA_NAME and a list of FIELD_NAMEs.

The following command will create a new schema called “persons” with three fields and produces an output message that confirms the schema creation:
$ ./new_schema.sh persons name age weight
NEW SCHEMA 'persons' WITH FIELDS 'name', 'age', 'weight' CREATED.

The information regarding schemas should be stored in a file called schemas.txt. Each line of that file contains the SCHEMA_NAME followed by the FIELD_NAMEs.
Below is an example schemas.txt file:

schemas.txt:
persons name age weight
grades course_name exam1 exam2 exam3
company employee address age


Your script should check if the SCHEMA_NAME already exists and if so it should print an appropriate error message and exit. If it doesn't exist, then the script should append the information to the end of the file and print a message that the schema has been created.

2- The second shell script should be named new_database.sh 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 new_database.sh script and response.

$ .new_database.sh persons svu_tutors
DATABASE ‘svu_tutors’ USING SCHEMA 'persons' HAS BEEN CREATED.


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:

databases.txt
svu_tutors persons
bit_student persons
firas_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.

3-The third shell script should be named insert_record.sh and its purpose is to insert a record into a database.
It accepts one argument, which is the DATABASE_NAME. The insert_record.sh script should then prompt the user for the values of the fields in that database.
After that the script should read in the field values and append these values in a new line to the end of the DATABASE_NAME.db file. Finally, the script should print a message that the new database record has been added.
For instance, below is an example session of using the insert_record.sh script. (Please note that the green field values would be entered by the user.)

$ ./insert_record.sh svu_tutors
ENTER VALUES FOR name age weight: Ahmad 42 75

RECORD ADDED TO " svu_tutors " DATABASE.


If the DATABASE_NAME does not exist in the databases.txt file or the DATABASE_NAME.db does not exist, then you should print an appropriate error message and exit.