Sponsored Content
Top Forums Shell Programming and Scripting Executing Sql Query Using Shell Script Post 302082176 by tmarikle on Monday 31st of July 2006 02:15:42 PM
Old 07-31-2006
Code:
Set the default file permissions 
umask 000
#
# Source in the home profile
#
Set the session environment if the file .profile exists in your home directory; I assume this is run from cron 
if [ -f $HOME/.profile ]
then
. $HOME/.profile
else
echo "ERROR: Error sourcing $HOME/.profile !" >> $EBPP_DATAFEED_LOGFILE
exit 10
fi

Define temp variables 
TMP_OUTPUT_FILE="temp_log.tmp"
TMPBATCHPROC="temp_batch.tmp"

Define a variable with today's date 
export CURRENT_FEED=`date +%Y-%m-%d`

Add to the session environment some stuff in this .rc file if it exists 
#
# Source in the environment variables (if possible)
#
if [ -f ./eBPPDataFeed_env.rc ]
then
. ./eBPPDataFeed_env.rc
fi
#

Add more to the session's environment 
# Set the error codes
#
. ./errorcodes.ksh

Add more to the session's environment (username and password probably 
#
# Obtain the secure username and password (if it exists)
#
if [ -f "$BATCH_USER_DIR/batch_user.ksh" ]
then
TMPPWD=`pwd` # v1.1
cd $BATCH_USER_DIR # v1.1
. ./batch_user.ksh # v1.1
RTNCD=$? # v1.1
cd $TMPPWD # v1.1

If previous script return a 0 result, set some Seibel username and password variables; otherwise exit script 
if [ $RTNCD = 0 ]
then
export SIEBEL_USERNAME=$USERID
export SIEBEL_PASSWORD=$PASSWORD
else
exit $EXIT_BATCHUSER_FAILED
fi
else
echo "ERROR: batch_user.ksh does not exist, unable to source in variables" >> $EBPP_DATAFEED_LOGFILE
exit $EXIT_BATCHUSER_DOESNOTEXIST
fi
#
# Check if the Environment Variables are set, if not, exit -1
#
Loop through a list of keywords... 
for i in SIEBEL_USERNAME SIEBEL_PASSWORD \
EBPP_DATAFEED_ROOT EBPP_DATAFEED_DATA EBPP_DATAFEED_SCRIPTS EBPP_DATAFEED_LOGS \
SIEBEL_DB_USERNAME SIEBEL_DB_PASSWORD SIEBEL_DB_ORACLESID SIEBEL_DB_TABLE_OWNER \
SIEBEL_ROOT EXIT_SUCCESS EXIT_ENV_MISSING EXIT_ENV_NOVALUE \
EXIT_SQLPLUSERROR EXIT_BATCHUSER_FAILED EXIT_BATCHUSER_DOESNOTEXIST MINERRORLEVEL
do
Search through environment variables for the keyword 
IS_SETF1=`env | grep "^$i=" | cut -d= -f1`
If the search was unsuccessful, say so and exit script 
if [[ -z $IS_SETF1 ]]
then
echo "FATAL: Environment Variable $i is not set, terminating process" >> $EBPP_DATAFEED_LOGFILE
exit $EXIT_ENV_MISSING
fi
Same thing but this time, check the variable's value 
IS_SETF2=`env | grep "^$i=" | cut -d= -f2`
Exit script if variable wasn't set 
if [[ -z $IS_SETF2 ]]
then
echo "FATAL: Environment Variable $i has no value, terminating process" >> $EBPP_DATAFEED_LOGFILE
exit $EXIT_ENV_NOVALUE
fi
done

 

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
platform::shell(n)					       Tcl Bundled Packages						platform::shell(n)

__________________________________________________________________________________________________________________________________________________

NAME
platform::shell - System identification support code and utilities SYNOPSIS
package require platform::shell ?1.1.4? platform::shell::generic shell platform::shell::identify shell platform::shell::platform shell _________________________________________________________________ DESCRIPTION
The platform::shell package provides several utility commands useful for the identification of the architecture of a specific Tcl shell. This package allows the identification of the architecture of a specific Tcl shell different from the shell running the package. The only requirement is that the other shell (identified by its path), is actually executable on the current machine. While for most platform this means that the architecture of the interrogated shell is identical to the architecture of the running shell this is not generally true. A counter example are all platforms which have 32 and 64 bit variants and where a 64bit system is able to run 32bit code. For these running and interrogated shell may have different 32/64 bit settings and thus different identifiers. For applications like a code repository it is important to identify the architecture of the shell which will actually run the installed packages, versus the architecture of the shell running the repository software. COMMANDS
platform::shell::identify shell This command does the same identification as platform::identify, for the specified Tcl shell, in contrast to the running shell. platform::shell::generic shell This command does the same identification as platform::generic, for the specified Tcl shell, in contrast to the running shell. platform::shell::platform shell This command returns the contents of tcl_platform(platform) for the specified Tcl shell. KEYWORDS
operating system, cpu architecture, platform, architecture platform::shell 1.1.4 platform::shell(n)
All times are GMT -4. The time now is 07:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy