<?xml version="1.0"?><!-- generator="bbPress" -->

<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
>

<channel>
<title>AskDBA.org Forum &#187; Topic: Executing SQL from Shell Script</title>
<link>http://www.forum.askdba.org/</link>
<description>AskDBA.org Forum &#187; Topic: Executing SQL from Shell Script</description>
<language>en</language>
<pubDate>Fri, 30 Jul 2010 08:54:21 +0000</pubDate>

<item>
<title>deepika.dhamija@gmail.com on "Executing SQL from Shell Script"</title>
<link>http://www.forum.askdba.org/topic/executing-sql-from-shell-script#post-114</link>
<pubDate>Thu, 24 Dec 2009 10:50:40 +0000</pubDate>
<dc:creator>deepika.dhamija@gmail.com</dc:creator>
<guid isPermaLink="false">114@http://www.forum.askdba.org/</guid>
<description>&#60;p&#62;Thanks Amit.&#60;/p&#62;
&#60;p&#62;I was able to execute the SQL using the command&#60;br /&#62;
sqlplus &#38;lt;username&#38;gt;/&#38;lt;password&#38;gt;@&#38;lt;orcl_sid&#38;gt;
&#60;/p&#62;</description>
</item>
<item>
<title>Amit Bansal on "Executing SQL from Shell Script"</title>
<link>http://www.forum.askdba.org/topic/executing-sql-from-shell-script#post-113</link>
<pubDate>Thu, 24 Dec 2009 06:59:48 +0000</pubDate>
<dc:creator>Amit Bansal</dc:creator>
<guid isPermaLink="false">113@http://www.forum.askdba.org/</guid>
<description>&#60;p&#62;Deepika,&#60;/p&#62;
&#60;p&#62;Please find response below&#60;/p&#62;
&#60;p&#62;1) Your first script has mistake. Should be like&#60;/p&#62;
&#60;p&#62;export ORACLE_SID=+ASM1&#60;br /&#62;
sqlplus / as sysdba &#38;lt;&#38;lt;EOF&#60;br /&#62;
select name, path from v$asm_disk;&#60;br /&#62;
exit&#60;br /&#62;
EOF&#60;/p&#62;
&#60;p&#62;2)&#60;/p&#62;
&#60;p&#62;node_list=&#60;code&#62;olsnodes&#60;/code&#62;&#60;br /&#62;
node1=&#60;code&#62;echo $node_list&#124;awk &#38;#39;{print $1}&#38;#39;&#60;/code&#62;&#60;br /&#62;
node2=&#60;code&#62;echo $node_list&#124;awk &#38;#39;{print $2}&#38;#39;&#60;/code&#62;&#60;br /&#62;
echo &#34;Node 1 is &#34; $node1&#60;br /&#62;
echo &#34;Node 2 is &#34; $node2&#60;/p&#62;
&#60;p&#62;Hope this helps
&#60;/p&#62;</description>
</item>
<item>
<title>deepika.dhamija@gmail.com on "Executing SQL from Shell Script"</title>
<link>http://www.forum.askdba.org/topic/executing-sql-from-shell-script#post-112</link>
<pubDate>Wed, 23 Dec 2009 07:25:14 +0000</pubDate>
<dc:creator>deepika.dhamija@gmail.com</dc:creator>
<guid isPermaLink="false">112@http://www.forum.askdba.org/</guid>
<description>&#60;p&#62;Hi,&#60;/p&#62;
&#60;p&#62;I have a two node RAC Cluster Setup (10R2) and I want to execute sql queries from a shell script, to be run as root.&#60;br /&#62;
I have the foll test.sh script&#60;/p&#62;
&#60;p&#62;#! /bin/bash&#60;br /&#62;
echo &#34;In BASH&#34;&#60;br /&#62;
sqlplus / &#38;lt;&#38;lt;+ENDOFSQL+&#60;br /&#62;
select name, path from v$asm_disk;&#60;br /&#62;
exit&#60;br /&#62;
+ENDOFSQL+&#60;br /&#62;
echo &#34;Back to Bash&#34;&#60;br /&#62;
exit&#60;/p&#62;
&#60;p&#62;and I get the foll O/P&#60;br /&#62;
In BASH&#60;/p&#62;
&#60;p&#62;SQL*Plus: Release 10.2.0.1.0 - Production on Wed Dec 23 07:25:32 2009&#60;/p&#62;
&#60;p&#62;Copyright (c) 1982, 2005, Oracle.  All rights reserved.&#60;/p&#62;
&#60;p&#62;ERROR:&#60;br /&#62;
ORA-12546: TNS:permission denied&#60;/p&#62;
&#60;p&#62;Enter user-name: SP2-0306: Invalid option.&#60;br /&#62;
Usage: CONN[ECT] [logon] [AS {SYSDBA&#124;SYSOPER}]&#60;br /&#62;
where &#38;lt;logon&#38;gt;  ::= &#38;lt;username&#38;gt;[/&#38;lt;password&#38;gt;][@&#38;lt;connect_identifier&#38;gt;] &#124; /&#60;br /&#62;
Enter user-name: Enter password:&#60;br /&#62;
ERROR:&#60;br /&#62;
ORA-12546: TNS:permission denied&#60;/p&#62;
&#60;p&#62;SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus&#60;br /&#62;
Back to Bash&#60;/p&#62;
&#60;p&#62;What permissions should for this?&#60;/p&#62;
&#60;p&#62;2) Also I need to know the node names of the nodes that form the clustre. I add the foll lines to my script&#60;br /&#62;
NODE_NAMES=&#60;code&#62;olsnodes&#60;/code&#62;&#60;br /&#62;
echo $NODE_NAMES&#60;/p&#62;
&#60;p&#62;ad I get O/P&#60;br /&#62;
linux-1 linux-2&#60;br /&#62;
Is it possible to store these space separated node names in diff variables that can then be used. (the number of nodes are variable)&#60;/p&#62;
&#60;p&#62;Any suggestion/advise is appreciated. Thanks
&#60;/p&#62;</description>
</item>

</channel>
</rss>
