I need some help from Oracle and UNIX expertise point of view.

I have two tables, METADATA_A and METADATA_B. I need to switch loading these tables. If we load METADATA_A today, the following
week we would have to load METADATA_B.

There is a public synonym "METADATA" that sits on top of these two tables.

1) Find out which table is in use right now by quering the public synonym..

PHP Code:
2) Truncate opposite table

3) Load opposite table

4) Validate by doing a count * on the table to check the rows loaded.

5) Finally, switch synonym

I would like to write a shell script that would call Oracle SQL scripts. The shell script would be used to authenticate to the database and then I would want to execute the SQL script from within the script.

Thanks in advance,