SQLPLUS -S option not working


 
Thread Tools Search this Thread
Operating Systems AIX SQLPLUS -S option not working
# 1  
Old 02-04-2015
SQLPLUS -S option not working

Hi All,

I am using the following script to run some sql on database but i am not getting the result. When i tried the same by removing "-s" option it is working fine but getting other things as well with my input as shown below. Can anyone please suggest why "-s" option is not working in AIX and reply an alternate option if available.

This is my code without sqlplus -s option

Code:
OUTPUT=$( sqlplus <usrname>/<passwd> <<EOF
set heading OFF termout ON trimout ON feedback OFF
set pagesize 0
select column1,column2 from tablename where column1=${FILENAME1};
exit;
EOF
)

and the ouput is as below:

Code:
SQL*Plus: Release 11.2.0.1.0 Production on Tue Feb 3 02:26:39 2015

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> SQL> SQL> STI101.412026.SIZE.zip
       4012

SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

How to remove all other data in the ouput apart from the values i actually required from sql


Thanks in advance.
# 2  
Old 02-04-2015
In what way is it 'not working'? Do you get any output/errors that we can see?


Could I also suggest that you move your credentials to the next line. If anyone does a ps -ef | grep sql whilst your code is running, they will see your credentials in clear text. Something more like:-
Code:
OUTPUT=$(sqlplus -s <<EOF
$usrname/$passwd
set heading OFF termout ON trimout ON feedback OFF
set pagesize 0
select column1,column2 from tablename where column1=${FILENAME1};
exit;
EOF
)

Of course, keeping the credentials secret if you code them in the script is another problem.....Smilie



Robin
This User Gave Thanks to rbatte1 For This Post:
# 3  
Old 02-05-2015
Thanks Robin.

I have used " sqlplus -silent " instead of sqlplus -s and it worked fine.

But i will take your suggestion for adding username and password in the next line instead of in the 1st line to prevent them from seen by others during execution.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

"SQLPLUS -S " is not working in one environment where same code is working in another

"SQLPLUS -S " is not working in one environment where same code is working in another getting below error =================================== SQL*Plus: Release 11.2.0.3.0 Production Copyright (c) 1982, 2011, Oracle. All rights reserved. Use SQL*Plus to execute SQL, PL/SQL and SQL*Plus... (1 Reply)
Discussion started by: yogendra.barode
1 Replies

2. Shell Programming and Scripting

Sqlplus not working through ssh

Hi Gurus, I was trying to execute sqlplus command remotely like ssh -q IP venkat@"which sqlplus" am getting error as which: no sqlplus in (/usr/local/bin:/bin:/usr/bin) if i connect manually and executing which sqlplus it working fine. Please help to fix the issue. Regard's Venky (7 Replies)
Discussion started by: venky.b5
7 Replies

3. Shell Programming and Scripting

Working with UTF char sqlplus

I have below SQL that I wasnt to run from a solaris machine using sqlplus select * from TABLE_NAME where regexp_like(field_value, 'Α|Β|Γ|Δ|Ε|Ζ|Η|Θ|Ι|Κ|Λ|Μ|Ν|Ξ|Ο|Π|Ρ|Σ|Τ|Υ|Φ|Χ|Ψ|Ω|α|β|γ|δ|ε|ζ|η|θ|ι|κ|λ|μ|ν|ξ|ο|π|ρ|σ|τ|υ|φ|χ|ψ|ω'); When I cat the file UTF char shows perfect however when i run... (1 Reply)
Discussion started by: varun22486
1 Replies

4. Shell Programming and Scripting

-v and -f option for grep not working

In solaris, i m trying to find the files having a particulat extension and then from the list i want to exclude those files which is present in a file. But it seems the -f and -v option are not working find $source -type f -name $extn | /usr/xpg4/bin/grep -F -v -f $exclude | while read... (7 Replies)
Discussion started by: millan
7 Replies

5. Shell Programming and Scripting

Sqlplus Set Heading not Working

Hello, Could someone tell me why this still returns headings? echo "SELECT columnA from tableA group by columnA;" | sqlplus -s ${DB_CONNECT} set heading OFF | while read line do arr="$line" echo ${arr} let i=$i+1 done (2 Replies)
Discussion started by: flowervz
2 Replies

6. Shell Programming and Scripting

sqlplus @ not working sqlplus \@ working..

Hi All, I am facing a strange problem on one of my unix servers. When i try to login using the standard method: it fails with below message >sqlplus REF1SSTDBO1/REF1SSTDBO1@TKS3N10G > TKS3N10G ksh: TKS3N10G: not found But it works perfectly when i escape with ;\ >sqlplus... (3 Replies)
Discussion started by: kunwar
3 Replies

7. HP-UX

who command option not working

Running HP 11.31 on a HP3600. But when I log in as a user the who command works but if I use an option like "who -m" I get nothing. Any thoughts on what is causing this problem. (11 Replies)
Discussion started by: KMRWHUNTER
11 Replies

8. Shell Programming and Scripting

Multiple SQLPLUS background processes not working properly

Hi All, I am running 25 background process from a Unix shell script which calls a single Oracle procedure with different paramenters each time. These 25 process creates 25 different files. When i run these 25 Background SQLPLUS processes, few files are not created completly but if i run 25... (1 Reply)
Discussion started by: rawat_me01
1 Replies

9. UNIX for Dummies Questions & Answers

-d option not working...

:confused: In the following, when I enter a valid, existing directory,why am I getting Not Found when the Dir DOES exist? read auser echo "You entered $auser" wait 2 cd /home if then echo "Dir Exists" sleep 2 else echo "/home/$auser Not Found" sleep... (2 Replies)
Discussion started by: rgouette
2 Replies

10. Solaris

Why does the 'ps' command with -u option not working?

How can I use the 'ps' command to view current sessions but only for a given process/user, with the -u parm? In older versions of Unix, this used to work, but not in Sun Solaris. Thanks (4 Replies)
Discussion started by: ElCaito
4 Replies
Login or Register to Ask a Question