Sponsored Content
Operating Systems Linux Red Hat Displaying command return in one line Post 302931467 by Ditto on Tuesday 13th of January 2015 09:16:41 AM
Old 01-13-2015
Quote:
Originally Posted by S. BASU
Hello all

I have a query (SQL) that returns a rather long field from an Oracle database. The field in question is defined on 400 characters but all these 400 cannot be displayed by the echo command. Thus when I launch the following command:

echo "SELECT FIELD01 FROM TABLE_NAME;" | sqlplus -s <login>/<password>@<CONNECTION_NAME> I get the folloiwng:

https://dec.parent_groupe.com/C10/cg...=cognosViewer&
ui.action=run&ui.object=storeID(%22i18DCC8B926BB446BA88844C3DFDED8A6%22)&ui.name
=Contr%c3%b4les%20ICARE&run.outputFormat=&run.prompt=true&cv.header=false&ui.bac
kURL=%2fC10%2fcps4%2fportlets%2fcommon%2fclose.html

Where as what I need is all of the above on one line.

Can anyone please help me out?

Thanks a lot

S. BASU
As an Oracle DBA, I'd strongly recommend some changes to the way you're doing things.

don't use:
Code:
sqlplus -s <login>/<password>@<CONNECTION_NAME>

That makes your password visible to anyone logged onto the system via
Code:
ps -ef

command

Instead ... consider doing something like:

Code:
sqlplus -s /nolog << EOF         
   connect <login>/<password>@<CONNECTION_NAME>
   @your_sql_script.sql
   exit
EOF

The advantages of using this structure over what you have are many:

1) keeps your password slightly more protected from prying eyes. it's much harder to sniff out (probably not impossible, but I'm not aware of a simple way to do it at this time).

2) you can build sql scripts in stand alone files, that actually "LOOK" like sql scripts. So they can have "set" commands at the start, var commands set if needed, parameters passed into them (using "&1", "&2", etc to catch them), and many queries if need be. Or as you need, even a simple, single SQL.

3) you can wrap unix braces around that block to capture all output in log file, variable, or whatever you need:

ie:
Code:
{
sqlplus -s /nolog << EOF         
   connect <login>/<password>@<CONNECTION_NAME>
   @your_sql_script.sql
   exit
EOF
}   > $my_log_file.log  2>&1

or you can assign it to a variable:

Code:
my_var = 
$(sqlplus -s /nolog << EOF         
   connect <login>/<password>@<CONNECTION_NAME>
   @your_sql_script.sql
   exit
EOF)

(that one's untested, sorry, I don't use that format alot myself)

but yeah, two main points are:

a) don't expose your password - use the connect keyword to delay the login and keep the password off the command line, or use External Ids, or some other login mechanism to help protect your password.
b) keep your sql in standalone sql scripts so you can easily test/modify it. Then all you need is "pass it through" to sql, via some wrapper, or such as above.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

displaying the first line?

how do i display just the first line of a file with the cat command or any command for that matter (4 Replies)
Discussion started by: imuuk
4 Replies

2. Shell Programming and Scripting

displaying the path in the command line

Hi all, Does anyone know how to ammend the .cshrc file in $HOME for your session to display the path as part of the command line? So that I dont need to keep on typing pwd to see where I am? thanks Ocelot (2 Replies)
Discussion started by: ocelot
2 Replies

3. UNIX for Dummies Questions & Answers

displaying mutliple fields on command line

This is probably the dumbest question you guys can get, but I'm trying, as a complete noob, to display the unix calendar for all the months without Saturday and Sunday showing. How can I remove those fields without having to type all the fields in individually such as: cal -y | awk '{print $2,... (3 Replies)
Discussion started by: Trellot
3 Replies

4. UNIX for Dummies Questions & Answers

Displaying Return Codes

This is a high-level explanation, if more details are needed, please do not hesitate to ask. I have a set of .ctl files which I want to execute: AV1.ctl AV2.ctl AV3.ctl I have a script which has a for loop in it: for filename in AV1 AV2 AV3 do . execute_another_script.sh done ... (2 Replies)
Discussion started by: hern14
2 Replies

5. UNIX for Dummies Questions & Answers

to pick up the Return Code ( RC) from the mailx command and return it to SAS uisng 's

Hi All, Can anyone please let me know the syntax / how to pick up the Return Code ( RC) from the mailx command and return it to SAS uisng 'system()' function and '${?}'. I am in a process to send the mail automatically with an attachment to bulk users. I have used 'Mailx' and 'Unencode'... (0 Replies)
Discussion started by: manas6
0 Replies

6. Shell Programming and Scripting

Insert a line including Variable & Carriage Return / sed command as Variable

I want to instert Category:XXXXX into the 2. line something like this should work, but I have somewhere the wrong sytanx. something with the linebreak goes wrong: sed "2i\\${n}Category:$cat\n" Sample: Titel Blahh Blahh abllk sdhsd sjdhf Blahh Blah Blahh Blahh Should look like... (2 Replies)
Discussion started by: lowmaster
2 Replies

7. Shell Programming and Scripting

How to get the return code of subroutines executed as standalone as command line in Perl ?

How to do I get the return code of a subroutine in a perl module if invoke the subroutine as standalone, I have an module say TestExit.pm and in that i have a subroutine say myTest() which is returns 12, if i were to call the subroutine from command line like CASE:1 ( Without an explict... (2 Replies)
Discussion started by: ennstate
2 Replies

8. UNIX for Dummies Questions & Answers

Can grep command return word instead of complete line

Hi Is there any way GREP command can return word and not complete line. My file has following data: Hello Everyone I am NitinrajSrivastava Hi Friends Welcome VrajSrivastava I am using grep 'raj' which is returning me complete line.However I want only the word having keyword 'raj'. Required... (11 Replies)
Discussion started by: dashing201
11 Replies

9. Shell Programming and Scripting

Why sed command deletes last line in a file if no carriage return?

Hi I am using sed command to make SCORE=somevalue to SCORE=blank in a file. Please see the attached lastline.txt file. After executing the below command on the file, it removes the last line. cat lastline.txt | sed 's/SCORE=.*$/SCORE=/g' > newfile.txt Why does sed command remove the... (3 Replies)
Discussion started by: ashok.k
3 Replies

10. UNIX for Beginners Questions & Answers

awk Command to add Carriage Return and Line Feed

Hello, Can someone please share a Simple AWK command to append Carriage Return & Line Feed to the end of the file, If the Carriage Return & Line Feed does not exist ! Thanks (16 Replies)
Discussion started by: rosebud123
16 Replies
All times are GMT -4. The time now is 02:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy