Sponsored Content
Top Forums Shell Programming and Scripting Function returns wrong values - solved Post 302399072 by xiamin on Friday 26th of February 2010 08:56:13 AM
Old 02-26-2010
Function returns wrong values - solved

Hi

I have a small function which returns a wrong value.
The function tries to make a connection to oracle database and tries to get the open_mode of the database in the variable status.

However when a database is down the value of the status column is set to READWRITE i am not sure why.

I also unset the status variable still no luck

Any ideas ?

Code:
get_db_status() {
unset status
echo "Entering DB STATUS scripts"
sid=$1
echo $sid
if ! check_sqlplus  "$sid" ; then
  echo "Unable to use sqlplus for sid $sid"
  return 1
else
  echo "attempting to connect to database"
  echo $status
  echo $ORA_HOME
  echo "Status before entering sqlplus is $status"
  status=`sqlplus -silent "/ as sysdba" <<EOF
  conn /as sysdba
  set pagesize 0 feedback off verify off heading off echo off
  select replace(open_mode,' ','')
  from v\\$database;
  exit;
EOF`
echo "current status is $status"
fi



---------- Post updated at 02:56 PM ---------- Previous update was at 01:33 PM ----------

Hi

Apologies i found my faux pause
Friday evening i had a brain fart

regards

Last edited by jim mcnamara; 02-26-2010 at 06:43 PM.. Reason: closed
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Wrong date function

Hi, I am getting some very strange output when using date function in PERL on Solaris. Infact the month portion is wrong and it is 1 less then the current, means today it is responding as month =3 , andthis should be 4 ------> April Any help my code is ($day, $month, $year) =... (3 Replies)
Discussion started by: Asteroid
3 Replies

2. Shell Programming and Scripting

function returns string

Can I create a function to return non-interger value in shell script? for example, function getcommand () { echo "read command" read command echo $command } command=$(getcommand) I tried to do something as above. The statement echo "read command" does not show up. ... (5 Replies)
Discussion started by: lalelle
5 Replies

3. Programming

what is wrong with the log function in c?

Hi I looked up the reference but couldn't figure out whats wrong with my log funtions in ANSI C, need this log functions for a memory compiler, please help!! #include <stdio.h> #include <math.h> int main(void) { double d ; double logB(double x, double base); printf(" ... (2 Replies)
Discussion started by: return_user
2 Replies

4. UNIX for Dummies Questions & Answers

dlsym() returns 0 for an existing function

Sometimes I observe this in gdb: (gdb) br my_function Breakpoint .. at 0x...: file ..., line ... i.e., "my_function" does exist in the current executable. however, dlsym does not find it: (gdb) p dlsym(0,"my_function") $6 = 0 This is a C program; dlsym does find other defined functions and... (2 Replies)
Discussion started by: sds
2 Replies

5. Shell Programming and Scripting

Whats wrong in the Function ?

Need your assistance, to find the bug in the function. Function usage erroring out even after passing parameters. usage() { if || ; then echo "************************************************************" echo " CHECK USAGE FOR CORRECT PARAMETERS ... (26 Replies)
Discussion started by: raghunsi
26 Replies

6. UNIX for Dummies Questions & Answers

grep returns many values into a variable error

I get an error when I grep my results into a variable when the grep finds more than one file. FND="$(find ediout* -mmin -60)" if ; then STR="$(find ediout* -mmin -60 -exec grep -l "ERRORS Encountered" {} +)" fi When there is only one ediout file it works fine. How do I... (11 Replies)
Discussion started by: aispg8
11 Replies

7. Shell Programming and Scripting

Function returns a value but cannot be stored in other variable

I need help to store the value returned from the function to one variable and then use that variable. PREVIOUS_DATE_FUNCTION() { date '+%m %d %Y' | { read MONTH DAY YEAR DAY=`expr "$DAY" - 1` case "$DAY" in 0) MONTH=`expr "$MONTH" - 1` case... (1 Reply)
Discussion started by: aroragaurav.84
1 Replies

8. UNIX for Dummies Questions & Answers

[Solved] ksh script - can't figure out what's wrong

Hi! (I guess this could of gone into the scripting forum, but Unix for Dummies seemed more appropriate. Please note that I am not in school, so Homework doesn't seem appropriate either. You guys can let me know if you think otherwise.) I am following an exercise in a book on ksh scripting which... (2 Replies)
Discussion started by: sudon't
2 Replies

9. Shell Programming and Scripting

Help in function returns value

Hi, I need to return a value from the function. the value will be the output from cat command which uses random fucntion. #!/bin/ksh hello() { var1=$(`cat /dev/urandom| tr -dc 'a-zA-Z0-9-!%&()*+,-/:;<=>?_'|fold -w 10 | head -n 1`) echo "value is" var1 return var1 } hello var=$?... (2 Replies)
Discussion started by: Nandy
2 Replies

10. Shell Programming and Scripting

Function Returns

I'm having a little trouble returning a value from a function or calling it, I'm not quite sure. I'm calling the function here function region_lookup_with_details { results = $(set_region) echo $results } This is the function I'm calling function set_region { ... (8 Replies)
Discussion started by: akechnie
8 Replies
UDM_ALLOC_AGENT(3)							 1							UDM_ALLOC_AGENT(3)

udm_alloc_agent - Allocate mnoGoSearch session

SYNOPSIS
resource udm_alloc_agent (string $dbaddr, [string $dbmode]) DESCRIPTION
Allocate a mnoGoSearch session. PARAMETERS
o $dbaddr -$dbaddr - URL-style database description, with options (type, host, database name, port, user and password) to connect to SQL database. Do not matter for built-in text files support. Format for $dbaddr: DBType:[//[DBUser[:DBPass]@]DBHost[:DBPort]]/DBName/. Currently supported DBType values are: mysql, pgsql, msql, solid, mssql, oracle, and ibase. Actually, it does not matter for native libraries support, but ODBC users should specify one of the supported values. If your database type is not supported, you may use unknown instead. o $dbmode -$dbmode - You may select the SQL database mode of words storage. Possible values of $dbmode are: single, multi, crc, or crc- multi. When single is specified, all words are stored in the same table. If multi is selected, words will be located in different tables depending of their lengths. "multi" mode is usually faster, but requires more tables in the database. If "crc" mode is selected, mnoGoSearch will store 32 bit integer word IDs calculated by CRC32 algorithm instead of words. This mode requires less disk space and it is faster comparing with "single" and "multi" modes. crc-multi uses the same storage structure with the "crc" mode, but also stores words in different tables depending on words lengths like in "multi" mode. Note $dbaddr and $dbmode must match those used during indexing. RETURN VALUES
Returns a mnogosearch agent identifier on success, FALSE on failure. This function creates a session with database parameters. NOTES
Note In fact this function does not open a connection to the database and thus does not check the entered login and password. Establish- ing a connection to the database and login/password verification is done by udm_find(3). PHP Documentation Group UDM_ALLOC_AGENT(3)
All times are GMT -4. The time now is 07:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy