How to call a script from another script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to call a script from another script?
# 1  
Old 12-14-2005
How to call a script from another script?

hi..
i have this script called test.cfg that needs to accept parameters and contains this codings:

load data
input_text=$1
table_name=$2
INFILE '$input_text'
append into table $table_name
fields terminated by '|'
(
THS_M,
THS_D,
THS_H,
THS_HT
)

I have another script name load.script that needs to call this script.
current_dir=`pwd`
...
...
$oracle_home...
............... control=test.cfg log="log/$2.log" bad="bad/$2.bad"

..
..

I got error in executing the load.script....i need to called test.cfg which needs to accept parameters too in the load.script...and the $2 in the load.script is the same value $2 in the test.cfg. anyone can help?? thanks Smilie

Last edited by forevercalz; 12-14-2005 at 05:33 AM..
# 2  
Old 12-14-2005
Hi,

Are you invoking sqlldr from the load.script?

You can call the sqlldr inside a shell script. But the command arguments($1,$2) will not be recognized in control file. You can include the command line parameter "Data" to dynamically change the data file. But i dont think that you can change the tablename dynamically by passing parameters.

Change your control file as below

Code:
load data
append into table table_name--please give the table name here.
fields terminated by '|'
(
THS_M,
THS_D,
THS_H,
THS_HT
)

This can be called as below from the shell script
Code:
sqlldr userid/pass@db control=test.cfg data=$1 log="log/$2.log" bad="bad/$2.bad

Regards,
Mona
# 3  
Old 12-14-2005
hi..mona..i changed it to ...control=test.cfg data=$1 ...... this in my load.script...and i get this error....
syntax error at 'data' following '='
Syntax error on command-line

Last edited by forevercalz; 12-14-2005 at 10:04 PM..
# 4  
Old 12-14-2005
What is $1?

If $1 is nothing, data=$1 will expand to data=

data=$1 will be your sqlldr flat file.
# 5  
Old 12-14-2005
thanks...it works now...i get this...
SQL*Loader: Release 9.2.0.5.0 - Production on Thu Dec 15 10:59:41 2005

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

Commit point reached - logical record count 6

but when i check the database...there are no records ..i should get 6 records ....but nothing is there....how come?
# 6  
Old 12-14-2005
Did you check the log and bad files?
# 7  
Old 12-14-2005
ok..thanks...i get it..thanks so much for great help....... Smilie Smilie Smilie Smilie Smilie Smilie Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell script to call and sort awk script and output

I'm trying to create a shell script that takes a awk script that I wrote and a filename as an argument. I was able to get that done but I'm having trouble figuring out how to keep the header of the output at the top but sort the rest of the rows alphabetically. This is what I have now but it is... (1 Reply)
Discussion started by: Eric7giants
1 Replies

2. Shell Programming and Scripting

awk script to call another script based on second column entry

Hi I have a text file (Input.txt) with two column entries separated by tab as given below: aaa str1 bbb str2 cccccc str3 dddd str4 eee str3 ssss str2 sdf str3 hhh str1 fff str2 ccc str3 ..... ..... ..... (1 Reply)
Discussion started by: my_Perl
1 Replies

3. Shell Programming and Scripting

Call a Perl script within a bash script and store the ouput in a .txt file

I'm attempting to write a bash script that will create a network between virtual machines. It accepts three arguments: an RSpec that describes the network topology, and two list of machines (servers and clients). I have a (working) Perl script that I want to call. This Perl script takes an RSpec... (6 Replies)
Discussion started by: mecaka
6 Replies

4. Shell Programming and Scripting

Shell script to call Oracle archive backup script when file system reaches threshold value

Hello All, I need immediate help in creating shell script to call archivebkup.ksh script when archive file system capacity reaches threshold value or 60% Need to identify the unique file system that reaches threshold value. ex: capacity ... (4 Replies)
Discussion started by: sasikanthdba
4 Replies

5. Shell Programming and Scripting

Script to call a menu script and redirect each option to a text file

Hello, I want to design a script that will call an existing menu script and select options one by one and redirict the out put to a file. For example;- In the script MENU.sh there are 10 options i want to design a script MENU2.sh that will select option 2 3 4 6 7 10 and redirict the output... (4 Replies)
Discussion started by: spradha
4 Replies

6. Shell Programming and Scripting

Call shell script function from awk script

hi everyone i am trying to do this bash> cat abc.sh deepak() { echo Deepak } deepak bash>./abc.sh Deepak so it is giving me write simply i created a func and it worked now i modified it like this way bash> cat abc.sh (2 Replies)
Discussion started by: aishsimplesweet
2 Replies

7. Shell Programming and Scripting

shell script to call perl script problems

Ok, don't ask me why, but all calls to perl must be called by a shell script. Its really not ideal, but its what I have to work with. Calling it isnt the issue, its passing in the arguments. I have about 1000 perl scripts to call by a shell script. Right now, I'm executing the shell script... (3 Replies)
Discussion started by: regexnub
3 Replies

8. Shell Programming and Scripting

how to run script? call other script? su to another user? make a cron?

Good morning. I am searching for "how-to"'s for some particular questions: 1. How to write a script in HP-UX 11. 2. How to schedule a script. 3. How to "call" scripts from the original script. 4. How to su to another user from within a script. This is the basics of what the... (15 Replies)
Discussion started by: instant000
15 Replies

9. Shell Programming and Scripting

call shell script from perl cgi script problem

hi,, i have perl scipt with line : system('./try.sh $t $d $m'); in shell scipt try.sh i have the line: echo $1 its not printing value of $t that i hav passed..y is it so..i am running it from apache web server (2 Replies)
Discussion started by: raksha.s
2 Replies

10. Shell Programming and Scripting

Call a perl script inside a shell script

Hi all, I have the following snippet of code.. #!/bin/sh echo "run perl script............" #Run the verification script perl bill_ver echo " perl script completed....." echo "rename files......" #Remove from all file in the directories test, test1, test2, test3 for f in... (3 Replies)
Discussion started by: chriss_58
3 Replies
Login or Register to Ask a Question