Visit Our UNIX and Linux User Community


Wrapper script to refresh test database with production data


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Wrapper script to refresh test database with production data
# 1  
Old 07-30-2009
Wrapper script to refresh test database with production data

Hi All,

I'm new here as well as to UNIX.

I need to write a wrapper script to refresh test database with production data. A set of tables are given as well as a particular data range. The script should prompt the user for both production and test logon credentials.

Pl. help me with this.

Thanks in advance.
Lini
# 2  
Old 07-30-2009
What database?

Are you on a SAN?

If the db is small you can export the db to tape or across your network, then import it. We need more information.
# 3  
Old 07-30-2009
thank you for replying...

Am on Sybase database(12.5). I have the following script ready. The requirement mentioned user should be prompted for source and target logon credentials.

#!/bin/sh
# Shell Script to do a complete refresh of table data from ODS schema
# PROMPTS FOR THE PRODUCTION AND QA SERVER NAME USER NAME AND PASSWORD
echo "Enter the production Server name or ip address"
read prod_server_nm
echo "Enter the production user name"
read prod_user_nm
echo "Enter the production Server password "
read prod_pwd
echo "Enter the QA Server name or ip address"
read QA_server_nm
echo "Enter the QA user name"
read QA_user_nm
echo "Enter the QA Server password "
read QA_pwd

#od_table_nm.txt is the file name in which the table names will be stored for ODS schema
var=`cat od_table_nm.txt`
for table_nm in $var; do
echo $table_nm
delete_table()
{
isql -S $QA_server_nm -U $QA_user_nm -P $QA_pwd<< EOF
use odstest
go
if exists ( select 1 from sysobjects where type = 'U' and name = $table_nm)
delete * from odstest..$table_nm
go
EOF
}
bcpout_data()
{
bcp odstest..$table_nm out ./$table_nm -S $prod_server_nm -U $prod_user_nm -c -e ./$table_nm.bcp_out_err_file.$$ <<!
$prod_pwd
!
}
bcpin_data()
{
echo "Loading the data into $table_nm table................"
bcp odstest..$table_nm in ./$table_nm -S $QA_server_nm -U $QA_user_nm -c -e ./$table_nm.bcp_in_err_file <<!
$QA_pwd
!
}

bcpout_data
bcpin_data
rm -f $table_nm
done

Previous Thread | Next Thread
Test Your Knowledge in Computers #325
Difficulty: Medium
Early RAM was not directly seated onto the motherboard so it could easily changed and upgraded.
True or False?

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help on Insert data to phpMyAdmin mySQL database from Shell Script

Sorry to disturb you, I would like to seek help on inserting data whenever the switch is on or off to my phpMyAdmin mySQL database from my Shell Script. I'm using Raspberry PI as my hardware and I have follow this LINK: instructables.com/id/Web-Control-of-Raspberry-Pi-GPIO/?ALLSTEPS to create my... (4 Replies)
Discussion started by: aoiregion
4 Replies

2. Shell Programming and Scripting

why do we need UNIX shell script to load data into Oracle database

Hello everyone, I am new to shell scripting/ loading data into a database. I want to load data into Oracle database using SQL loader. Can some one please explain why do we need unix shell script to load the data into the database? Also can someone please explain what has to be in that script?... (5 Replies)
Discussion started by: new_prog
5 Replies

3. Shell Programming and Scripting

Database Connection test in unix Script

i have a unix script that gives me the sysdate from the database EDNAMID.WORLD.What i want my script to do the following 1) Establish a database connection 2) if database connection is successfull then echo the message "Connected" 3) put the o/p of the Sql query in a spool file 4) then... (3 Replies)
Discussion started by: ali560045
3 Replies

4. Shell Programming and Scripting

Sample ksh script for copy the data from excel to database table ?

Hi All, I need to convert the data from excel to database table in sybase. Please provide some sample script.. thanks, Royal. (1 Reply)
Discussion started by: royal9482
1 Replies

5. Shell Programming and Scripting

unix script for loading a data from a file into database

Hi All, I am trying to load a data from a files in a particular directory to a database.. cd $SCC isql metdb >> ${LOGDATA}/LOAD.LOG < ! load from "${LDATA}/${FORM}.ld" insert into $LOADTABLE ! But it's showing the error "syntax error at line 46 : `<<' unmatched" Can u plz help me... (5 Replies)
Discussion started by: grajesh_955
5 Replies

6. Shell Programming and Scripting

Need shell script to extract data from oracle database

shell script (4 Replies)
Discussion started by: frns5
4 Replies

7. UNIX for Dummies Questions & Answers

Refresh ls list on screen (auto-refresh)?

I am looking for a way to issue a command or string of commands to repeatedly display new files that are written to the directory. I usually use ls -ltr to see the newest files at the bottom of the screen. I would like to automate this command to refresh what is displayed every second or so. Can... (3 Replies)
Discussion started by: skidude
3 Replies

8. Shell Programming and Scripting

Need Shell Script to upload data from Text file to Oracle database

Hi Does any one have any idea on uploading the data using Unix Shell script from text file to Oracle database. Requirement:- 1. Need to connect to Oracle database from Unix Shell script. 2. Need to pick Text file from some location on Unix Box. 3. Need to upload the data from text file to... (6 Replies)
Discussion started by: chandrashekharj
6 Replies

9. Shell Programming and Scripting

unix script to export data from csv file to oracle database

Hello people, Need favour. The problem I have is that, I need to develop a unix shell script that performs recurring exports of data from a csv file to an oracle database. Basically, the csv file contains just the first name and last name will be dumped to an Unix server. The data from these... (3 Replies)
Discussion started by: vinayagan
3 Replies

Featured Tech Videos