Sponsored Content
Top Forums Shell Programming and Scripting Executing Sql Query Using Shell Script Post 302081884 by tmarikle on Friday 28th of July 2006 12:14:57 PM
Old 07-28-2006
Not exactly as you have asked but that doesn't sound like your problem. Here is one method:

Code:
sqlplus -s /nolog <<EOF > youroutputfile
connect un/pw@db            <== login credentials inside here document
<your sql>;
EOF

If sqlplus can't be found then ${ORACLE_HOME}/bin is not in your path. If that is not in your path then you probably didn't prepare your environment properly by invoking /usr/local/bin/oraenv.

Code:
EXPORT ORACLE_SID=yoursid
EXPORT ORAENV_ASK=N
. /usr/local/bin/oraenv

sqlplus -s /nolog <<EOF > youroutputfile
connect ...
...
EOF

You can also use a named pipe to log in to the database as follows:
Code:
mknod /tmp/loginfile.sql p

print "connect un/pw" > /tmp/loginfile.sql &       <== login credentials in a sql script temporarily
sqlplus -s /nolog <<EOF > youroutputfile
@/tmp/loginfile.sql
...
EOF

You must provide login credentials in order to query the database. Your DBA can configure accounts that allow you to not specify any username or password as you have been given examples for. If your DBA defines accounts using OPS$ prefix, then you can log in as follows:
Code:
sqlplus -s / <<EOF >yourloginfile.sql    <== login credentials tied to your os login
...
EOF

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Executing a SQL query from a shell script

I cannot figure out how to run a SQL script, or just a sqlplus query, from a shell script (bash or ksh). Basically, I need to su - oracle from root and run a query, then test the exit status. (3 Replies)
Discussion started by: 98_1LE
3 Replies

2. Shell Programming and Scripting

executing a SQL query in shell script

Hi ALL, I need an help in connecting to oracle database, executing a select query and printing it on the screen. Can any one please write a simple code or psuedo code and let me know. select query returns multiple values( say select name from emp) Thanks in advance LM (1 Reply)
Discussion started by: lijju.mathew
1 Replies

3. Shell Programming and Scripting

Script executing sql query

Hello, I have a sh script excuting a sql query through sqlplus. I am having trouble making my date equal to the date of the server time in the sql script. How can i call the server date from my query? Thanks (2 Replies)
Discussion started by: kingluke
2 Replies

4. Shell Programming and Scripting

query sql using shell script

query sql using shell script, is it possible? my friend told me to do a file.sql and link to my shell script, but can i query sql using shell script? thanks in advance! (2 Replies)
Discussion started by: kingpeejay
2 Replies

5. UNIX for Dummies Questions & Answers

executing SQL query using unix shell script

I want to perform few post-session success tasks like update a status to 'true' in one of the sql database table, update date values to current system date in one of the configuration table in sql. How do i achieve this in a post session command?syntax with example will be helpful. (3 Replies)
Discussion started by: nathanvaithi
3 Replies

6. Shell Programming and Scripting

Executing a shell script from a PL / SQL Block

Hi, I need to call a shell script present on solaris server from within a PL / SQL block. Kindly suggest.. Thanks Sudhir (1 Reply)
Discussion started by: sudhird
1 Replies

7. Shell Programming and Scripting

Executing SQL Query and sending a mail

Hi all, My reqirenet goes like this. Need to execute one select statement within the script and send a mail to the users with the number of records fecthed from the query. Please help.. Thanks. (3 Replies)
Discussion started by: Achiever
3 Replies

8. UNIX for Dummies Questions & Answers

Regarding executing sql query in shell script

Hi, I have one SQL file prepared in UNIX and one script that is executing that. In SQL i have Update and create queries. I want to introduce conditions in SQL file (in UNIX) that if either of the create or update query failes whole transaction should be rollback. I just have 1 create... (2 Replies)
Discussion started by: abhii
2 Replies

9. Red Hat

Sql query through shell script

hey , i am using this code to store value of a sql query and and then use it in other query but after some time , but it is not working. please help #!/bin/bash val_1=$( sqlplus -s rte/rted2@rel76d2 << EOF setting heading off select max(stat_id) from cvt_stats; exit EOF ) nohup... (5 Replies)
Discussion started by: ramsavi
5 Replies

10. UNIX for Beginners Questions & Answers

Help with Executing sql in Shell Script

Hello~ I have a requirement to write a shell script which will connect to the oracle database and run a select count(*) query on a table. The script should succeed only when the count returns a number greater than zero. If the count returns zero, the script should fail. Can someone please... (3 Replies)
Discussion started by: Naren.N
3 Replies
gnome-sound-properties(1)					   User Commands					 gnome-sound-properties(1)

NAME
gnome-sound-properties - enable sound, and associate sounds with events SYNOPSIS
gnome-sound-properties [gnome-std-options] DESCRIPTION
The Sound preference tool enables you to control when the GNOME sound server starts. You can also specify which sounds to play when partic- ular events occur. OPTIONS
The following options are supported: gnome-std-optionStandard options available for use with most GNOME applications. See gnome-std-options(5) for more information. EXAMPLES
Example 1: Launching the Sound preference tool example% gnome-sound-properties EXIT STATUS
The following exit values are returned: 0 Application exited successfully >0 Application exited with failure FILES
The following files are used by this application: /usr/bin/gnome-sound-proExecutable for the Sound preferences tool. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+------------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+------------------------------+ |Availability |SUNWgnome-desktop-preferences | +-----------------------------+------------------------------+ |Interface stability |External | +-----------------------------+------------------------------+ SEE ALSO
Preference Tools Manual Latest version of the GNOME Desktop User Guide for your platform. libesd(3), gnome-control-center(1), gnome-std-options(5) NOTES
Written by Glynn Foster, Sun Microsystems Inc., 2003. SunOS 5.10 2 Oct 2003 gnome-sound-properties(1)
All times are GMT -4. The time now is 09:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy