Combining two shell scripts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Combining two shell scripts
# 1  
Old 10-27-2010
Error Combining two shell scripts

Hi readers,
I have two shell scripts running on linux machine.
Both the scripts do the following task
- Connect to DB
- Create temp files
- run select statement on table
- write the rows returned on temp file

Sample code is below
Code:
#!/bin/sh
export ORACLE_HOME=/content/oracle/10.2.0
echo "columns" >  /home/user/filename_$(date +%m%d%Y).txt;
/home/oracle/10.2.0/bin/sqlplus -s dbuser@schema/password << EOF > /home/user/filename_$(date +%m%d%Y).txt
SET LINESIZE 1000
SET PAGESIZE 1000
SET HEADING OFF
SET ECHO OFF
SET FEEDBACK OFF
select  statement with where clause;
exit;
EOF

Both the shell scripts do the same process but create separate temp files based on where clause. two files have difference of only where clause.

How can I combine the process and generate temp files using 1 shell script.
I tried replicating the code and inserting in 1 shell file but only 1 temp file was generated with "where clause 1".

Please advice.

Thanks
Manu
# 2  
Old 10-27-2010
This is much easier with a SQL "spool" command.
The logfile names can be Shell variables if required.

Code:
spool first_logfile_name
select  statement with where clause;
spool off
spool second_logfile_name
select  statement with where clause;
spool off

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Combining two scripts into a single script

Hi Folks, I have two scripts that are used to start and stop services these scripts are at the location /opt/app/tre , so that start.sh internally starts the components and stop.sh internally stop all the components, now rite now if I have to stop the services then i need to go first the... (9 Replies)
Discussion started by: punpun66
9 Replies

2. Shell Programming and Scripting

Combining two awk scripts

I have a file like this consisting of blocks separated by > of two number X and T > 10 0 13 5.92346 16 10.3106 19 13.9672 22 16.9838 25 19.4407 28 21.4705 31 23.1547 34 24.6813 37 26.0695 40 27.3611 43 28.631 46 29.8366 49 30.9858 52 32.0934 55 33.1458 (6 Replies)
Discussion started by: kristinu
6 Replies

3. Shell Programming and Scripting

calling 'n' number of shell scripts based on dependency in one shell script.

Hello gurus, I have three korn shell script 3.1, 3.2, 3.3. I would like to call three shell script in one shell script. i m looking for something like this call 3.1; If 3.1 = "complete" then call 3.2; if 3.2 = ''COMPlete" then call 3.3; else exit The... (1 Reply)
Discussion started by: shashi369
1 Replies

4. Shell Programming and Scripting

Shell Scripts

deleted (1 Reply)
Discussion started by: zxc
1 Replies

5. Shell Programming and Scripting

combining two scripts

Hi , Following are the two scripts :- Script 1) #!/bin/sh cp file.log file.log.1 Script 2) #!/bin/sh diff file.log file.log.1 > DIFFERENCE.log cp file.log file.log.1 grep "ERROR" DIFFERENCE.log if ; then echo "1" else echo "0" fi (1 Reply)
Discussion started by: himvat
1 Replies

6. HP-UX

Shell Scripts

I have a text file . Format of text file. djss:xd:78:isdev:"test server" this type of row. (approx 30). I want to display like that 1. djjs@msxd testserver 2. xjfd@msxd devserver 3. 4 select any one from above choice : 1... (5 Replies)
Discussion started by: rastogideepak
5 Replies

7. AIX

Shell Scripts

I would like to seek some expertise of all our AIX experts on board. 1) I would like know how to get a return exit code of a command. I found that there are exist code for each and every command run in AIX but I just can't get the return code from my scripts. A=`cp /home/abc/abc.txt... (7 Replies)
Discussion started by: kwliew999
7 Replies

8. Shell Programming and Scripting

Combining 2 scripts

Hello I am new to shell scripting. Below are 2 scripts which I need to combine in to single script.Can some experts guide me how to proceed? #!/bin/bash grep "2443" /f/log/s/heduler.log | grep 2443> /tmp/memorydump exec 6<"/tmp/memorydump" read -u 6 data if then echo "IN THEN" <... (4 Replies)
Discussion started by: achararun
4 Replies

9. AIX

Difference between writing Unix Shell script and AIX Shell Scripts

Hi, Please give me the detailed Differences between writing Unix Shell script and AIX Shell Scripts. Thanks in advance..... (0 Replies)
Discussion started by: haroonec
0 Replies

10. Shell Programming and Scripting

shell scripts help

Hi, I am not experienced in shell scripts, I hope someone can give some hint for the following problem I have html file like this <html> <body> Some stuff More stuff <pre> A B </pre> Still more stuff And more <pre> C D </pre> Additional stuff </body> (2 Replies)
Discussion started by: ccp
2 Replies
Login or Register to Ask a Question