RE: unix Ksh script variable
Date: Tue, 1 Feb 2011 08:04:57 -0500
Message-ID: <C95D75DD2E01DD4D81124D104D317ACA1601440323_at_JAXMSG01.crowley.com>
Yes I did this as well, using vbscript, and using korn-shell/awk (easier).
From your unix box, create a password function, that returns you password. Then you can reuse it in any script.
Remember also that your script will have to 'branch' for SYS as it connects 'as sysdba', or the other option depending on which user is running the script, not to have a password for sys at all. '/ as sysdba'.
Joel Patterson
Database Administrator
904 727-2546
-----Original Message-----
From: oracle-l-bounce_at_freelists.org [mailto:oracle-l-bounce_at_freelists.org] On Behalf Of Walker, Jed S
Sent: Monday, January 31, 2011 9:36 AM
To: A Joshi
Cc: oracle-l_at_freelists.org
Subject: RE: unix Ksh script variable
Why not just pass in the username as the parameter
Script sys
$1 is then sys (or whatever username you want to pass in)
-----Original Message-----
From: oracle-l-bounce_at_freelists.org [mailto:oracle-l-bounce_at_freelists.org] On Behalf Of Martijn Bos
Sent: Monday, January 31, 2011 5:04 AM
To: A Joshi
Cc: oracle-l_at_freelists.org
Subject: Re: unix Ksh script variable
Hi,
My idea for your question
Can't you use:
echo $usr
My idea for a sligthly different approach:
I would not define all the variables in the script itself. If it was up to me I would create a "config-file" which looks like: <sid1>:<user-to-login-with1>:<password-for-this-user1> <sid2>:<user-to-login-with2>:<password-for-this-user2>
... ... ...
Then in your script loop through the config-file. With awk you can get alle the variables you need for connecting
Best Regards,
Martijn Bos
On Sun, Jan 30, 2011 at 07:55:04PM -0800, A Joshi wrote:
> hi
> I have a script which is to be executed on many databases and different databases have different log in users/password. Login needs to be chosen based on parameter passed so if the parameter passed is 1 it needs to choose user1 and so on. I will be doing sqlplus $usr_at_$DB and need usr to have the value sys in this case and so on
> it is something like -
> user1=sys
> user2=system
> user3=emp
> pw1=x
> pw2=xx
> pw3=xxx
> #number=$1
> number=1
> us=user
> usr=$us$number
> export user1 user2 user3 number us usr
> export pw1 pw2 pw3
> echo $user1
> I tried in below ways but it is not working
> echo $usr
> export $usr ="$user1"
> echo $usr
>
> echo ${!$usr}
> echo ${!usr}
> echo $"$usr"
> echo `echo $"$usr"`
> can someone help.thanks in advance
>
>
>
> --
> http://www.freelists.org/webpage/oracle-l
>
>
-- Met vriendelijke groet, Martijn Bos (06 39477001) -- http://www.freelists.org/webpage/oracle-l -- http://www.freelists.org/webpage/oracle-l -- http://www.freelists.org/webpage/oracle-lReceived on Tue Feb 01 2011 - 07:04:57 CST