Call Script with Parameter (that has another parameter)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Call Script with Parameter (that has another parameter)
# 1  
Old 12-16-2014
Tools Call Script with Parameter (that has another parameter)

Hi.

How do I achieve this

Code:
sh /EDWH-DMT02/script/MISC/exec_sql.sh "@/EDWH-DMT02/script/others/CSM_CKC/Complete_List.sql ${file_name}" Complete_List.txt

The /EDWH-DMT02/script/MISC/exec_sql.sh has two parameters and it's working fine with this
Code:
sh /EDWH-DMT02/script/MISC/exec_sql.sh @/EDWH-DMT02/script/others/CSM_CKC/Complete_List.sql Complete_List.txt

But now I have to pass a single parameter called ${file_name} that has been set on top to the @/EDWH-DMT02/script/others/CSM_CKC/Complete_List.sql as well.

So how should I write the syntax?

Thank you very much.

Last edited by rbatte1; 12-19-2014 at 01:36 PM.. Reason: Grammar
# 2  
Old 12-17-2014
That depends entirely on the contents of exec_sql.sh, and what "put on top" means.
# 3  
Old 12-22-2014
Lightbulb

Quote:
Originally Posted by Corona688
That depends entirely on the contents of exec_sql.sh, and what "put on top" means.
Oh sorry for not being really clear.

What I actually mean is that the ${file_name} variable is predefined before the command
Code:
sh /EDWH-DMT02/script/MISC/exec_sql.sh "@/EDWH-DMT02/script/others/CSM_CKC/Complete_List.sql ${file_name}" Complete_List.txt

the exec_sql.sh is simply to accept two parameters
1. SQL command to be executed (in this case I pass the script file)
2. The filename of the spool file
Code:
sqlplus -s /nolog <<EOF
@/home/oracle9/dba_area/logon_credentials.sql

spool $2.txt
---------------------------------------------------------------------------------------
$1
/
commit
/

spool off
EOF

And the Complete_List.sql...
Code:
spool complete_$1.list
select $1||'_'||to_char(sysdate,'YYYYMMDD')||'.csv' from dual union
select $1||'_'||to_char(sysdate-1,'YYYYMMDD')||'.csv' from dual union
select $1||'_'||to_char(sysdate-2,'YYYYMMDD')||'.csv' from dual
;
spool off

So any ideas?

Thanks a lot.
# 4  
Old 12-24-2014
Please help me.

Thank you.
# 5  
Old 12-24-2014
What is your script is currently doing?

What do want your script to do that it is not doing?

Do you really want to spool output to Complete_List.txt.txt instead of Complete_List.txt? (I.e., why spool $2.txt instead of spool $2?)
# 6  
Old 12-24-2014
You're quite sparse with information you supply. Wildly guessing, I infer that you want to modify the spool file name in spool complete_$1.list. If so, what do you get with the setup you posted? Does it spool to complete_${filename}.list? If not, were it OK to rename the file afterwards?
# 7  
Old 01-20-2015
Quote:
Originally Posted by RudiC
You're quite sparse with information you supply. Wildly guessing, I infer that you want to modify the spool file name in spool complete_$1.list. If so, what do you get with the setup you posted? Does it spool to complete_${filename}.list? If not, were it OK to rename the file afterwards?
Thanks.

Yes, you are right.

After I pass this phase, I will rename the file with this:
Code:
mv complete.list ${grp}_complete.list

$grp is another parameter that I have set in the full script.

The idea of this is because I have 3 sets of file pattern. So I am trying to make the script global by maintaining all the common steps except for the pattern.

Thank you.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Call script parameter based on dates

Hi Guys, I am having a script which needs to be iterated based on date passed and itrate based on no of months given. #!/bin/bash var_d=$1 months=$2 sh invoke_script var_d i need to iterate the inside script something like below sh invoke_script 170101 sh invoke_script... (4 Replies)
Discussion started by: Master_Mind
4 Replies

2. Shell Programming and Scripting

To call Oracle procedure by reading parameter file in UNIX

hi Guys, is there a way to pass parameter into oracle store procedure by reading date range in file and increment accordingly. Something like this file.txt 01-JAN-2015 03-JAN-2015 sqlplus -s user/pwd@DB execute TEST( to_date( '01-JAN-2015, 'dd.mm.yyyy' ), to_date( '03-JAN-2015', ... (1 Reply)
Discussion started by: rohit_shinez
1 Replies

3. Shell Programming and Scripting

Resolving a parameter which is passed as parameter

Hi, I have the following files. ->cat scr.sh export TMP_DIR=/home/user/folder1 export TMP_DIR_2=/home/user/folder2 while read line do cat "$line" done<file_list.dat ------------------------ -> cat file_list.dat $TMP_DIR/file1.txt $TMP_DIR_2/file2.txt --------------------------- -> cat... (6 Replies)
Discussion started by: barath
6 Replies

4. Shell Programming and Scripting

How to get the parameter value from the parameter file in perl?

hi all, i have a parameter file of following format, i want a method which can get the value of specific parameter. parameter file format: <Parameter Name="FileLocationWindows"> <Description> The directory location of the logger file. ... (1 Reply)
Discussion started by: laxmikant.hcl
1 Replies

5. Shell Programming and Scripting

Passing parameter to script, and split the parameter

i am passing input parameter 'one_two' to the script , the script output should display the result as below one_1two one_2two one_3two if then echo " Usage : <$0> <DATABASE> " exit 0 else for DB in 1 2 3 do DBname=`$DATABASE | awk -F "_" '{print $1_${DB}_$2}` done fi (5 Replies)
Discussion started by: only4satish
5 Replies

6. Shell Programming and Scripting

Command that takes one parameter and then searches for the passed in parameter

Hi I am looking for a unix command or a small shell script which can takes one parameter and then searches for the passed in the parameter in any or all files under say /home/dev/ Can anyone please help me on this? (3 Replies)
Discussion started by: pankaj80
3 Replies

7. Shell Programming and Scripting

How to call stored procedure with CLOB out parameter from shell script?

I have written a stored procedure in oracle database, which is having a CLOB OUT parameter. How can i call this stored procedure from shell script and get the CLOB object in shell script variable? (0 Replies)
Discussion started by: vel4ever
0 Replies

8. AIX

Audit problem : A system call received a parameter that is not valid.

while i try to start the audit i have the below error message . audit>audit start ** auditing enabled already A system call received a parameter that is not valid. please advice (6 Replies)
Discussion started by: thecobra151
6 Replies

9. Shell Programming and Scripting

Not getting the out value parameter of a DB call in the ksh file

Hi all Im calling a DB procedure as foll sqlplus -s $DB_USERID/$DB_PASSWD@$DB_NAME<<eof var var1 VARCHAR2(200); exec ODAS_BATCH_JOBS_RETRIEVE.retrieve_user_info(:var1); eof echo $var1 This echo is giving a blank. Also in case the package ODAS_BATCH_JOBS_RETRIEVE is in an un compiled... (2 Replies)
Discussion started by: Sam123
2 Replies

10. Shell Programming and Scripting

how do I make dynamic parameter names? Or get the value of a parameter evaluated twi

Say I write something like the following: var1=1 var2=2 for int in 1 2 do echo "\$var$int" done I want the output to be: 1 2 Instead I get something like: $var1 $var2 (2 Replies)
Discussion started by: Awanka
2 Replies
Login or Register to Ask a Question