Sponsored Content
Full Discussion: variables and functions
Top Forums Shell Programming and Scripting variables and functions Post 302683777 by BeefStu on Wednesday 8th of August 2012 01:56:52 PM
Old 08-08-2012
variables and functions

can somebody telll me what my values are not being displayed in the function func1()

Code:
 
{oracle@im4s012nz1_DUMMY}$ cat x1.ksh
#!/bin/ksh
getpwd()
(
set -x
   . /home/oracle/dba/bin/CyberArk/CyberArk_GetPass.ksh
   ORA_USER=$DB_UID
   ORA_PWD=$DB_PWD
   echo "Here I am 1 |DB_UID=$DB_UID|"
   echo "Here I am 1 |DB_PWD=$DB_PWD|"
   echo "Here I am 1 |ORA_USER=$ORA_USER|"
   echo "Here I am 1 |ORA_PWD=$ORA_PWD|"
)
func1()
{
   set -x
   getpwd
   echo "Here I am 2 |DB_UID=$DB_UID|"
   echo "Here I am 2 |DB_PWD=$DB_PWD|"
   echo "Here I am 2 |ORA_USER=$ORA_USER|"
   echo "Here I am 2 |ORA_PWD=$ORA_PWD|"
}
func1
 
 
when I run it
 
+ getpwd
+ . /home/oracle/dba/bin/CyberArk/CyberArk_GetPass.ksh
+ safe_name=2-AAQ-BA0-Oracle-A-A-000
+ psswordobj=Oracle_us_dba_maint_dev-ORADBAD
+ app_id=Oracle-A-1.0
+ instance_name=ORADBAD
+ DB_SERVER=ORADBAD
+ + /opt/CARKaim/sdk/clipasswordsdk getpassword -p AppDescs.AppID=Oracle-A-1.0 -p Query=safe=2-AAQ-BA0-Oracle-A-A-000;Folder=Root;Object=Oracle_us_dba_maint_dev-ORADBAD -o PassProps.UserName
UID=dba_maint
+ + /opt/CARKaim/sdk/clipasswordsdk getpassword -p AppDescs.AppID=Oracle-A-1.0 -p Query=safe=2-AAQ-BA0-Oracle-A-A-000;Folder=Root;Object=Oracle_us_dba_maint_dev-ORADBAD -o Password
PWD=f0ur3y3s
+ export DB_UID=dba_maint
+ export DB_PWD=f0ur3y3s
+ ORA_USER=dba_maint
+ ORA_PWD=f0ur3y3s
+ echo Here I am 1 |DB_UID=dba_maint|
Here I am 1 |DB_UID=dba_maint|
+ echo Here I am 1 |DB_PWD=f0ur3y3s|
Here I am 1 |DB_PWD=f0ur3y3s|
+ echo Here I am 1 |ORA_USER=dba_maint|
Here I am 1 |ORA_USER=dba_maint|
+ echo Here I am 1 |ORA_PWD=f0ur3y3s|
Here I am 1 |ORA_PWD=f0ur3y3s|
+ echo Here I am 2 |DB_UID=|
Here I am 2 |DB_UID=|
+ echo Here I am 2 |DB_PWD=|
Here I am 2 |DB_PWD=|
+ echo Here I am 2 |ORA_USER=|
Here I am 2 |ORA_USER=|
+ echo Here I am 2 |ORA_PWD=|
Here I am 2 |ORA_PWD=|

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Variables and functions

I have a script that ultimately will FTP data to certain directories based on a character in the filename. I am creating a function within my script to handle the FTP call. Are the variables that are setup in the original script accessible to the function? If not, is there a way to allow them to... (4 Replies)
Discussion started by: dfb500
4 Replies

2. Shell Programming and Scripting

awk - arithemetic functions with external variables

I'm trying to get awk to do arithmetic functions with external variables and I'm getting an error that I cannot figure out how to fix. Insight would be appreciated money=$1 rate1=$(awk -F"\t " '/'$converting'/{print $3}' convert.table) rate2=$(awk -F"\t"... (2 Replies)
Discussion started by: DKNUCKLES
2 Replies

3. Programming

How to convert byteArray variables to HexaString variables for Linux?

Hello everybody, I am having problem in converting byte array variables to Hexa String variables for Linux. I have done, converting byte array variables to Hexa String variables for Windows but same function doesn't work for linux. Is there any difference in OS ? The code for Windows is given... (2 Replies)
Discussion started by: ritesh_163
2 Replies

4. Programming

Trouble with Date Variables and Functions in PL/SQL

Hi, In the course of my script i have to compare SYSDATE with the 15th of the current month: if it is greater than i should set a variable date to 15th of the next month if less than i should set it to the 15th of the current month. In other words the question is how to set a date variable... (2 Replies)
Discussion started by: fmina
2 Replies

5. Shell Programming and Scripting

[bash] reassigning referenced variables in functions

Hello all, Problem. ---------- I'm trying to reassign a referenced variable passed to a 'local' variable in a function but the local variable refuses to be assigned the content of the referenced variable. Any ideas would be appreciated. Objective. ----------- Eliminate all $VAR... (1 Reply)
Discussion started by: ASGR
1 Replies

6. Shell Programming and Scripting

functions and variables in bash

I have a bash script with some functions as below and am wondering if I can use the variables declared in setup in the other functions and in the rest of the bash script. setup(){ none=0; low=1; medium=2; high=3; debug=4 var1="red" var2="fred" } create_basemap() { ... (7 Replies)
Discussion started by: kristinu
7 Replies

7. Shell Programming and Scripting

How to execute functions or initiate functions as command line parameters for below requirement?

I have 7 functions those need to be executed as command line inputs, I tried with below code it’s not executing function. If I run the ./script 2 then fun2 should execute , how to initiate that function I tried case and if else also, how to initiate function from command line if then... (8 Replies)
Discussion started by: saku
8 Replies

8. Shell Programming and Scripting

awk - Why can't value of awk variables be passed to external functions ?

I wrote a very simple script to understand how to call user-defined functions from within awk after reading this post. function my_func_local { echo "In func $1" } export -f my_func_local echo $1 | awk -F"/" '{for (k=1;k<=NF;k++) { if ($k == "a" ) { system("my_local_func $k") } else{... (19 Replies)
Discussion started by: sreyan32
19 Replies

9. Shell Programming and Scripting

Passing awk variables to bash variables

Trying to do so echo "111:222:333" |awk -F: '{system("export TESTO=" $2)}'But it doesn't work (2 Replies)
Discussion started by: urello
2 Replies

10. Shell Programming and Scripting

ksh While Loop - passing variables to functions

I'm reading a text file using a while loop but when I call a function from within this loop it exits that same iteration … even though there are many more lines in the file to be read. I thought it was something to do with the IFS setting but it appears that a function call (when run... (3 Replies)
Discussion started by: user052009
3 Replies
echo(1B)					     SunOS/BSD Compatibility Package Commands						  echo(1B)

NAME
echo - echo arguments to standard output SYNOPSIS
/usr/ucb/echo [-n] [argument] DESCRIPTION
echo writes its arguments, separated by BLANKs and terminated by a NEWLINE, to the standard output. echo is useful for producing diagnostics in command files and for sending known data into a pipe, and for displaying the contents of envi- ronment variables. For example, you can use echo to determine how many subdirectories below the root directory (/) is your current directory, as follows: o echo your current-working-directory's full pathname o pipe the output through tr to translate the path's embedded slash-characters into space-characters o pipe that output through wc -w for a count of the names in your path. example% /usr/bin/echo "echo $PWD | tr '/' ' ' | wc -w" See tr(1) and wc(1) for their functionality. The shells csh(1), ksh(1), and sh(1), each have an echo built-in command, which, by default, will have precedence, and will be invoked if the user calls echo without a full pathname. /usr/ucb/echo and csh's echo() have an -n option, but do not understand back-slashed escape characters. sh's echo(), ksh's echo(), and /usr/bin/echo, on the other hand, understand the black-slashed escape characters, and ksh's echo() also understands a as the audible bell character; however, these commands do not have an -n option. OPTIONS
-n Do not add the NEWLINE to the output. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWscpu | +-----------------------------+-----------------------------+ SEE ALSO
csh(1), echo(1), ksh(1), sh(1), tr(1), wc(1), attributes(5) NOTES
The -n option is a transition aid for BSD applications, and may not be supported in future releases. SunOS 5.10 3 Aug 1994 echo(1B)
All times are GMT -4. The time now is 10:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy