passing values to the shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting passing values to the shell script
# 1  
Old 09-19-2011
passing values to the shell script

Hi,

Solaris : 10 .
I have 3 database in single file system i.e. /d01 . whenever I connect to oracle user using the below method
Code:
#su -  oracle

It will prompt for which database environment you want to set(PROD,TEST,UAT) :

whichever i need i will enter required DATABASE and perform my task.

I have an requirement to update one table in the PROD database i create one script for that DATABASE and want to schedule in crontab and execute it every 10 minutes . but when I am executing that script it is asking for which database u want to connect ??
any help how to write PROD in my shell script So that he should not prompt for which DATABASE and finish my sql query task.
*********AccUnlock.sh********
Code:
#!/bin/ksh
ORACLE_HOME=/prod_ora/proddb/9.2.0
export ORACLE_HOME
ORACLE_SID=PROD
export ORACLE_SID
$ORACLE_HOME/bin/sqlplus -s "/as sysdba"  > /prod_ora/scripts/check_$ORACLE_SID.ora
UPDATE GOBTPAC SET GOBTPAC_PIN_DISABLED_IND ='N' WHERE GOBTPAC_PIDM 
in (SELECT SPRIDEN_PIDM FROM SPRIDEN WHERE SPRIDEN_ID like '432%');
commit;
exit

*********************************

Last edited by Scott; 09-19-2011 at 11:26 AM.. Reason: Use code tags, pelase...
# 2  
Old 09-19-2011
Check the "connect" command of sqlplus.
# 3  
Old 09-19-2011
Yes, you'll need to connect as someone after connecting with "/ as sysdba" - assuming that the table being updated doesn't belong to the sys user, although I suppose as the sys user you can update pretty much anything you like. Nice and dangerous, like root!. Perhaps using "/nolog" instead of "/ as sysdba", then "connect" is what you need?

If su - oracle is prompting you for a database name (after, of course prompting you for Oracle's password), then it's coming from the Oracle .profile (or something called from it upon login) - either from "oraenv" or other hand-written code.

If the cronjob should run as Oracle, then simply don't source the .profile in the script, and it will likely not ask which DB to connect to when it's run.

You need to correct the script, though as it is missing some bits.

Code:
#!/bin/ksh
ORACLE_HOME=/prod_ora/proddb/9.2.0
export ORACLE_HOME
ORACLE_SID=PROD
export ORACLE_SID
$ORACLE_HOME/bin/sqlplus -s "/as sysdba"  <<! > /prod_ora/scripts/check_$ORACLE_SID.ora
CONNECT ????/????
UPDATE GOBTPAC SET GOBTPAC_PIN_DISABLED_IND ='N' WHERE GOBTPAC_PIDM 
in (SELECT SPRIDEN_PIDM FROM SPRIDEN WHERE SPRIDEN_ID like '432%');
commit;
exit;
!

I also prefer using "oraenv" when setting the Oracle environment, than trying to do it manually:

Code:
ORAENV_ASK=NO
. oraenv PROD

If the job should run as someone other than Oracle, then "su - oracle" won't cut it, and you should look at using sudo.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing values to an XML file from shell script

:wall: Hi, I have an XML file with 5 tags. I need to pass values to the XML file from a shell script that will replace values in 2 of the tags. I cannot hardcode the tag values in XML and use replace command in script as the values are likely to change. Please help !!!!!!!!!!! (2 Replies)
Discussion started by: Monalisaa
2 Replies

2. Shell Programming and Scripting

Query the table and return values to shell script and search result values from another files.

Hi, I need a shell script, which would search the result values from another files. 1)execute " select column1 from table_name" query on the table. 2)Based on the result, need to be grep from .wft files. could please explain about this.Below is the way i am using. #!/bin/sh... (4 Replies)
Discussion started by: Rami Reddy
4 Replies

3. Shell Programming and Scripting

Passing values from awk to shell variable

I am writing a script where I need awk to test if two columns are the same and shell to do something if they are or are not. Here is the code I'm working with: @ test = 0 ... test = `awk '{if($1!=$2) print 1; else print 0}' time_test.tmp` #time_test.tmp holds two values separated by a space... (3 Replies)
Discussion started by: Malavin
3 Replies

4. Shell Programming and Scripting

Passing PERL var values to SH Shell Script

Greetings all, If I have a SH script that calls a PERL script in the following way: perl $HOME/scripts/config.properties And in the config.properties PERL file, this Perl script only sets a number of environmental parameters in the following way: #!/usr/bin/perl $VAR1 = ( ... (3 Replies)
Discussion started by: gikyo12
3 Replies

5. Shell Programming and Scripting

Handling values with space while passing commandline argument from wrapper script in KSH

Hi there, I have a wapper script which passes the argument from command prompt to inner script.. It works fine as long as the argument containing single word. But when value contains multiple word with space, not working as expected. I tried my best, couldn't find the reason. Gurus, pls.... (2 Replies)
Discussion started by: kans
2 Replies

6. UNIX for Advanced & Expert Users

Passing the values to the secondary script when it invoked by primary script

Hi, When I invoke a script s1.sh it will call an another script s2.sh by itself. This script s2.sh will call some java files, so while running the script it asks for a file name to be processed. Which we can see in the screen. The file name to be processed is present in script s1.sh Now I... (2 Replies)
Discussion started by: venu_eie
2 Replies

7. Shell Programming and Scripting

Passing the values to the secondary script when it invoked by primary script

Hi, When I invoke a script s1.sh it will call an another script s2.sh by itself. This script s2.sh will call some java files, so while running the script it asks for a file name to be processed. Which we can see in the screen. The file name to be processed is present in script s1.sh Now... (1 Reply)
Discussion started by: venu_eie
1 Replies

8. Shell Programming and Scripting

passing values from sql to shell script

Hi guyz, Posting a thread after a long time. I want to pass two variables to unix shell script from sql script. Note: I am calling sql script from unix script. sql script has 2 variables one is the return code for status of program run and second one email flag. I don't know how to capture... (3 Replies)
Discussion started by: sachin.gangadha
3 Replies

9. Shell Programming and Scripting

Passing Values from a shell script

Hi all I want to know how to pass value from one shell script to another suppose i have script named A.This 'A.sh' calls 'B.sh' .Now some calculations are done by B.sh ..Say in variable X. Now i want to pass the value of this X variable to 'A.sh'... A.sh ----> B.sh ( X variable ) ... (6 Replies)
Discussion started by: dhananjaysk
6 Replies

10. Programming

Passing Parameters and getting values back from a c program to Shell script

I am having a shell script which has to be called from a C program. I have to pass two parameters to this script. HOw can I do that? eg: int main() { char st1; char str2; // call a shell script call_sh(str1,str2) where call_sh is the name of the shell script. then i need to get the return... (5 Replies)
Discussion started by: Rajeshsu
5 Replies
Login or Register to Ask a Question