I have a shell script where I have to connect t oracle database. I have to store the command in a variable and then run the command through the variable.The OS is solaris 10 and the shell is bash.pls help when I run the command it doesnot work.Thanks.
Last edited by vbe; 05-06-2014 at 07:11 PM..
Reason: code tags please not HTML
Hi thanks a lot . It worked , I have another problem as when I am redirecting the output to a file it doesn't connect to database.Pls suggest.thanks in advance
Last edited by Don Cragun; 05-07-2014 at 01:18 AM..
Reason: Change HTML tags to CODE tags.
This question made me worry when I saw it, and that's why -- take it to its natural conclusion and it stops working. Shell doesn't work that way... It will split spaces, but it won't start over from scratch and assume that everything in your string is shell syntax. That'd be dangerous, and if you want dangerous, you have to use eval to forcefeed it to the shell. That'll ensure that a string containing <<EOF, >redirection, any accidental spaces and quotes, and/or `rm -Rf ~/` will be processed as the shell literally would instead of fixed string contents.
So the answer, the real answer, is "don't do that". Otherwise, 6 months down the road, you're going to try and read your own code and have no idea what its doing because commands are defined 3 if-statements deep, 9 pages away from where they're used, and run via recursive recursive eval. It'll be your job to figure out what elusive injected quote, brace, bracket, backtick, or dollar sign is making your generated-code-generator explode and fix it -- or more likely give it a proper rewrite into this:
Don't use variables to store commands. The shell has to do a lot of doublethink to handle that and is left open to lots of bugs and mistakes you'd be better off avoiding. Use variables to store the parts of the command that vary.
Last edited by Corona688; 05-06-2014 at 08:18 PM..
Thanks a lot. Not only you solved my problem but also showed me the better way to do it. Very very thankful. Not to mention your explanation was great.
Hi All,
I have below variable,
xyz=\$AI_XFR
Now, if you will run the below command
=> echo $xyz
$AI_XFR
It is returning hardcoded string value.
Whereas in environment, there is value in it. Like below:
=> echo $AI_XFR
/home/aditya/sandbox/xfr/
I need to resolve this... (4 Replies)
hey, i have stored values of query like this
val_2=$( sqlplus -s rte/rted1@rel75d1 << EOF
set heading off
select source_id from cvt_istats where istat_id > $val_1;
exit
EOF
)
echo $val_2
now , val_2 has five values displayed like this
1
2
3
4
5
what i have to do is to check the... (1 Reply)
Hi Everyone,
I want to create a script where i need to run the oracle stored procedure from unix script and get the output(sequence number ) into a variable which i will pass in my datastage job.
Below is my stored procedure:-
DECLARE
P_TRANSTYPE VARCHAR2(20);
... (4 Replies)
Hello all,
I am trying to run stored procrdure from shell script which takes one argument. And also I want to verify in the script whether the script executed successfully. However the Stored procedure is not running from shell script. Manually if I run it update the data in the table.
Can... (29 Replies)
Hi,
Good Day,
I had this question in my mind.Hope someone can give me his/her thought about it.
Question: I had a binary files stored in the nfs system and mounted several workstation locally and running as deamon. Is there in effect to the networks or any problem me arise regarding network... (3 Replies)
can anyone please help me with this:
i have written a shell script and a stored procedure which has one OUT parameter. now i want to use that out parameter as an input to the unix script but i am getting an error as variable not found. below are the unix scripts and stored procedure...
... (4 Replies)
When I run this:
PDHDURL=`/usr/bin/curl --silent http://www.phdcomics.com/comics.php | /usr/bin/grep -o http://www.phdcomics.com/comics/archive/.*.gif | head -1`
echo -e "$PHDURL"
It is totally blank. However, when I just run it from the terminal:
/usr/bin/curl --silent... (2 Replies)
Hi,
I am trying to do the following thing
var='date'
$var
Above command substitutes date for and in turn runs the date command and i am getting the todays date value.
I am trying to do the same thing as following, but facing some problems,
unique_host_pro="sed -e ' /#/d'... (3 Replies)
Hi all,
I have a variable say var1 (output from somewhere, which I can't change)which store something like this:
echo $var1
name=fred
age=25
address="123 abc"
password=pass1234
how can I make the variable $name, $age, $address and $password contain the info?
I mean do this in a... (1 Reply)
hi
the code i ve written is as follows:
command="egrep ',100,|,200,' | wc -l"
count =`cat trial.txt | $command`
echo "$count"
the contents of
trial.txt is :
000,100,200,300,
001,200,100,201,
002,200,100,400,
i need to get the count using the command stored in a variable and using... (2 Replies)