Passing parameter inside the expression


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Passing parameter inside the expression
# 1  
Old 03-02-2015
Passing parameter inside the expression

Hello,

i need to pass the variable in place of pwd. how to display variable in the bleow syntax.
suppose, passwd="test", then 'id/$passwd.....
Code:
 FEDFlagResult=`sqlplus -S 'id/pwd@(DESCRIPTION= (ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1643))(CONNECT_DATA=  (SID=peta1)))'<< EOF
select count   from country
exit;
EOF`

note: there is a ` at the begining and ' before id. so, $passwed needs to be added inside of these 2 ( ` and ' )


Regards
B


Moderator's Comments:
Mod Comment Code tags please

Last edited by vbe; 03-02-2015 at 11:55 AM..
# 2  
Old 03-02-2015
Two comments:
- replace (deprecated) `...` with (recommended) $(...)
- try "'" in place of the single quotes '
# 3  
Old 03-03-2015
hello,

sqlplus is giving syntax error for the below .. pls suggest.

Code:
=`sqlplus -S id/'$passwd'@(DESCRIPTION ........


Last edited by Don Cragun; 03-03-2015 at 06:17 PM.. Reason: Add CODE tags again.
# 4  
Old 03-03-2015
Did you listen to anything anyone said?
# 5  
Old 03-03-2015
Quote:
Originally Posted by balareddy
hello,

sqlplus is giving syntax error for the below .. pls suggest.

Code:
=`sqlplus -S id/'$passwd'@(DESCRIPTION ........

You have shown us an assignment statement with no variable being assigned, an opening backquote with no closing backquote, a variable that won't be expanded inside single quotes, and an open parenthesis without a closing parenthesis. Except for not expanding a variable inside singe quotes, all of these are syntax errors.

Show us the complete statement. Show us the exact diagnostic produced. Explain why you chose to ignore the suggestions RudiC made.

And, please, use CODE tags when showing us sample input, output, and code.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing parameter more than 9

Hi, I've written a script where eleven parameter to be passed from command line which is inserting into an oracle table, it is working but the tenth and 11th parameter are not accepting as given it is referring to 1st parameter. HERE IS THE SCRIPT #!/bin/ksh #set -o echo $*... (4 Replies)
Discussion started by: sankar
4 Replies

2. 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

3. UNIX for Dummies Questions & Answers

Parameter Expansion with regular expression

Hello experts, I am exploring parameter expansion, and trying to cut the fields in a URL. Following is the requirement: I have // abc.nnt /dir1/dir2/dir3/dir4/somefile.java What i need to get is the path after dir3, and dir3 will be passed. output that i need is... (1 Reply)
Discussion started by: gjarms
1 Replies

4. Programming

passing float parameter

I am surprised by GCC (this is ver. 4.2.4, Ubuntu 32 bit Intel) when a function declares a float parameter and it's prototype is missing, the parameters are messed up. Please see my code below: ~/test$ cat x1.c #include <stdio.h> #include <stdlib.h> set_p(int p1, float p2, int p3, int p4)... (7 Replies)
Discussion started by: migurus
7 Replies

5. Shell Programming and Scripting

Passing in regular expression as a parameter to sed

Hi All, Im using Bash. I have a pipe delimited config file which contains 3 columns, 1st column = location of a file to be chnaged 2 column = expression to find within file 3rd column = string to replace. A script will loop through the contetnts of this file and apply the changes using... (2 Replies)
Discussion started by: satnamx
2 Replies

6. Shell Programming and Scripting

Passing a parameter to AWK

Hi All, I am trying to pass a parameter to AWK on my KSH shell prompt as below. var1=2 echo $var1 awk -v var2=${var1} '{print var2}' testfile.txt I am passing the input file (testfile) to awk to get some o/p. It is having 10 records. When I run AWK, it is throwing the following errors... (1 Reply)
Discussion started by: Raamc
1 Replies

7. Shell Programming and Scripting

Positional parameter passing

Hi All, When passing parameters to a sheel script, the parameters are referenced by their positions such as $1 for first parameter, $2 for second parameter. these positional values can only have values ranging from $0-$9 (0,1,2,3...9). I have a shell script meant to accept 20 parameters. for... (3 Replies)
Discussion started by: ogologoma
3 Replies

8. Shell Programming and Scripting

Regular expression as parameter

Hello everybody, I have a problem with creating a script which allows a single parameter to be passed. Sorry if I'm not expert, I'm new at this and . The code is if ; then echo "Something" exit fi ...does other things... grep -i $1 $TEMPUSERS > $USERSFILE COUNT=`wc -l... (3 Replies)
Discussion started by: Gnappo
3 Replies

9. Programming

Passing parameter to makefile?

Hi, How to pass parameter to makefile? Please let me know if any one knows and also please put an example of makefile with this feature. thanks, Manju. (3 Replies)
Discussion started by: manju_p
3 Replies

10. Shell Programming and Scripting

parameter passing

Hallo everyone, This is my problem below: /home/cerebrus/pax=>vat class2.sh ksh: vat: not found /home/cerebrus/pax=>cat class2.sh #!/bin/ksh set -x bdf|grep appsdev|awk '{ print $5 }'> class3 dd={cat class3} echo $dd /home/cerebrus/pax=> /home/cerebrus/pax=>./class2.sh + bdf +... (8 Replies)
Discussion started by: kekanap
8 Replies
Login or Register to Ask a Question