LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 11-22-2010, 05:21 PM   #1
smritisingh03
Member
 
Registered: Nov 2010
Posts: 43

Rep: Reputation: 0
Unhappy executing .sql files in shell script


Hi All

i have n files and each file has 5-6 .sql files.Now I need to wrie a shell script that executes all the n files in parellel and for each n file the .sql files sequentially.eg

CRM_File CM_file AP_file

crm_file_1425.sql
cm_file_5789.sql
ap_file_4124.sql
crm_file_1426.sql
cm_file_5788.sql
ap_file_4124.sql
crm_file_1427.sql
cm_file_5787.sql
crm_file_1428.sql

i want to run CRM_File CM_file AP_file in parellel and
each file under CRM_File,CM_file,AP_file sequentially.Please Help and thanx a lot in advance.

Last edited by smritisingh03; 11-23-2010 at 09:55 AM.
 
Old 11-23-2010, 01:38 AM   #2
somupl86
LQ Newbie
 
Registered: Nov 2010
Posts: 13

Rep: Reputation: 0
SOMA

I did not get what you exactly needed.
For running scripts parllely , you cannot do any thing in shell script.you can use cronjobs for that.

You can execute sql script in shell script as follows.

/opt/ORACLE/bin/sqlplus batch/databasebatch@DATABASE /data01/scripts/execute.sql


Thanks,
Soma
 
Old 11-23-2010, 02:26 AM   #3
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,477

Rep: Reputation: 87
Hmm... for those you want to run in parallel, why not just use the & symbol?

E. g. to make two BASH scripts run in parallel:

Code:
sh -f script_1.sh &
sh -f script_2.sh &
?
 
Old 11-23-2010, 09:56 AM   #4
smritisingh03
Member
 
Registered: Nov 2010
Posts: 43

Original Poster
Rep: Reputation: 0
nope...i think i did not explain my question clearly.I need to run the CRM ,CM and AP in parellel and all the sqls under each sequentailly.I think i need to create child processes....please help...
 
Old 11-23-2010, 10:47 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,004
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Sorry, I still have no idea what you're trying to do there. How do you normally
"run" your CRM, CM and AP files? How do they relate to the sql files (apart from
the obvious names)?



Cheers,
Tink
 
Old 11-23-2010, 11:23 PM   #6
smritisingh03
Member
 
Registered: Nov 2010
Posts: 43

Original Poster
Rep: Reputation: 0
the ARM,CM etc are module names under which there are n sql files that need to be executed.suppose the ARM module has 5 sql files then these 5 sql files would get executed sequentially but the modules should run in parellel.i have been able to write the script for one module.the sql files are running sequentially but now i ve to make the sql files in other modules run in parellel.i know i can establish it by forking the child process but since i ve just started unix i ve not reached that level.please help.the code written till now is:

#!/bin/sh
#!/usr/bin/awk -f
#export file2="temp_file2"
rm -f temp_file1
rm -f temp_file2
rm -f temp_file3
rm -f file_unique_modules
rm -f *SQL_LIST*
echo -n "Enter directory name:"
read dname


ls -l $dname | grep -v '^d' >> temp_file2

awk '{print $9}' temp_file2 >> temp_file3

while read temp_file3_line
do
string=$temp_file3_line
module_name="$(echo $string | cut -d '_' -f 2)"
echo $module_name >> temp_file1
done <temp_file3

awk '{print $0}' temp_file1 | sort -u >> file_unique_modules

while read module_name

do

file_name="${module_name}_SQL_LIST.sql"
echo $file_name
touch $file_name
done <file_unique_modules

while read temp_file3_line
do
string=$temp_file3_line
module_name="$(echo $string | cut -d '_' -f 2)"
echo $temp_file3_line >> "${module_name}_SQL_LIST.sql"
done <temp_file3
. DBSQLExecute
while read line

do

VAR1=$line
echo calling function
SQL_CONN_CODE="sa/sa@conCRM5"
#. DBSQLExecute
DBSQLExecute $VAR1 $SQL_CONN_CODE
#DBSQLExecute sa sa conCRM5 ARFB_CRM_5106.sql
echo returned from function

the function is as:::::::
#!/bin/sh -vx
echo inside DBSQL
DBSQLExecute()
{
echo value of 1 is $1
echo value of 2 is $2
echo $$ >sql.pid
cd ARFB
#sqlplus -s ${SQL_CONN_CODE} < $1
sqlplus -s $2 < $1
echo connected
sleep 5
}
~
~this code is running 5 .sql files in one module.there are 8 other modules like this and under each module there are 6-9 .sql filesto be run sequentially.i hope i ve been clear.please guide!!!!
~
~
 
Old 11-24-2010, 11:23 AM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,004
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
I'm still not sure about that "in parallel" part. You have no guarantee
that the jobs will all run the same time; so it's quite possible that
the list of 6 ARMs completes before the 5th CM has been started.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Executing a Shell script with 654 permissions inside another shell script. changusee2k Linux - Newbie 2 06-07-2011 08:58 PM
Problem in executing a shell script ursvmg Linux - Newbie 1 05-19-2009 10:35 AM
oppinion wanted on executing an sql script frieza Programming 2 03-05-2009 04:51 PM
executing multiple files (one after another) through shell script bilal_linux Programming 1 07-07-2007 02:31 AM
executing a shell script from C llama_meme Programming 2 04-01-2002 10:10 PM


All times are GMT -5. The time now is 05:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration