Sponsored Content
Top Forums Shell Programming and Scripting Passing a parameter from a shell script to sqlplus Post 302843850 by durden_tyler on Thursday 15th of August 2013 10:42:07 AM
Old 08-15-2013
Code:
$
$
$ cat -n per12.sql
     1  begin
     2    dbms_output.put_line ('You entered PID = ' || '&1');
     3    dbms_output.put_line ('You entered PEE = ' || '&2');
     4  end;
     5  /
     6
$
$
$ cat -n myscript.sh
     1  #!/bin/bash
     2  TERM=vt100
     3  export TERM
     4  WORKDIR=/mnt/sr_scripts/PER
     5  export WORKDIR
     6  #cd $WORKDIR
     7
     8  DEV="dev" #this is dev environment.
     9  TEST="test" #this is TEST environment.
    10
    11  echo "Enter Environment"
    12  read mENV
    13  echo "Enter a valid PERSON_ID for the employee:"
    14  read PID
    15  echo "Display Payroll Element Entries (Y|N):"
    16  read PEE
    17
    18  if [ "$mENV" == "$DEV" ]; then
    19    LOGIN="apps/apps"
    20  elif [ "$mENV" == "$TEST" ]; then
    21    LOGIN="apps/apps123"
    22  fi
    23
    24  sqlplus -silent $LOGIN @per12.sql $PID $PEE <<EOF
    25    -- other stuff that you may want to do in sqlplus here...
    26    exit
    27  EOF
    28
$
$
$ ./myscript.sh
Enter Environment
dev
Enter a valid PERSON_ID for the employee:
100
Display Payroll Element Entries (Y|N):
Y
old   2:   dbms_output.put_line ('You entered PID = ' || '&1');
new   2:   dbms_output.put_line ('You entered PID = ' || '100');
old   3:   dbms_output.put_line ('You entered PEE = ' || '&2');
new   3:   dbms_output.put_line ('You entered PEE = ' || 'Y');
You entered PID = 100
You entered PEE = Y
 
PL/SQL procedure successfully completed.
 
Elapsed: 00:00:00.21
$
$
$ ./myscript.sh
Enter Environment
test
Enter a valid PERSON_ID for the employee:
200
Display Payroll Element Entries (Y|N):
N
old   2:   dbms_output.put_line ('You entered PID = ' || '&1');
new   2:   dbms_output.put_line ('You entered PID = ' || '200');
old   3:   dbms_output.put_line ('You entered PEE = ' || '&2');
new   3:   dbms_output.put_line ('You entered PEE = ' || 'N');
You entered PID = 200
You entered PEE = N
 
PL/SQL procedure successfully completed.
 
Elapsed: 00:00:00.21
$
$

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

passing parameters from a shell script to sqlplus

Hi , I want to pass parameters from a shell script to a sql script and use the parameter in the sql query ..and then I want to spool a particular select query on to my unix box... for 4 different locations by writing only one sql script Right now no file is generated on the unix box...it is a... (2 Replies)
Discussion started by: phani
2 Replies

2. Shell Programming and Scripting

error in passing a variable to sqlplus from a shell script

hi, I am using a shell script from where i will be conecting to sqlplus.. i am having a problem in passing a variable to sqlplus query.. i will be assigning the variable in the unix environment..whenever i am trying to pass a variable having the contents greater than 2500 characters, i am... (3 Replies)
Discussion started by: kripssmart
3 Replies

3. Shell Programming and Scripting

How to pass parameter from sqlplus(procedure completed) to your shell script

if then # mail -s "Import failed file does not exist" sanjay.jaiswal@xyz.com echo "FILE does not exist" exit 1 fi echo "FILE EXIST" size=-1 set $(du /export/home/oracle/nas/scott21.dmp.gz) while do echo "Inside the loop" size=$1 set $(du... (1 Reply)
Discussion started by: sanora600
1 Replies

4. Shell Programming and Scripting

Passing parameter from one file to shell script

Hi All, I have a 2 files. File1 i am generating using an ETL tool, which is a comman seperated delimited file which contains country code & load date. everytime, this country code will be updated from a table. It might be AB or BA & ld_date will be for which date we need to load the file. ... (7 Replies)
Discussion started by: Amit.Sagpariya
7 Replies

5. AIX

Passing a parameter to a shell script?

I would like to run a compress script on files in certain directories. My compress_script.sh is just basically compress file* In order for me to use this I have to copy it into each directory and run it. How can I state the directory on the command line with the compress script so it... (2 Replies)
Discussion started by: NycUnxer
2 Replies

6. SCO

Parameter passing to dot shell script

OS SCO Open Server 6.0 MP4 I am trying to change the value of a enviornment variable thru a script and want to pass a parameter on the commande line, If I hard code the value inside the script the script changes the enviornment variable . mytest where my test is MYVAR=$1 export MYVAR... (6 Replies)
Discussion started by: atish0
6 Replies

7. Shell Programming and Scripting

Passing Parameter containing space in between to Shell Script

Hi, I have one shell script which use two parameter however one of its parameter have space in between. eg. a.sh 20110114 b c d here b c d is one parameter I used 'b c d' but its not giving correct result. Also i tried b\c\d but this one also didnt work. Any help would be... (5 Replies)
Discussion started by: diehard
5 Replies

8. UNIX for Dummies Questions & Answers

Passing a Unix parameter to SQLPlus login command

hi All, i m trying to pass a user choice paramter from unix to sqlplus connect command here i want the user to enter the username and password he wants to connect in sql plus through read in unix and then automatically connect to that instance. sqlplus -s $1/$2 where $ 1 and $2 will b... (2 Replies)
Discussion started by: Jcpratap
2 Replies

9. Shell Programming and Scripting

Shell Script passing parameters to sqlplus code

Hello All, I am interested in finding out a way to pass parameters that are entered at the prompt from HP unix and passed to SQLPlus code with a Shell Script. Is this possible? Thanks (4 Replies)
Discussion started by: compprog11
4 Replies

10. Shell Programming and Scripting

Passing parameter with single quote to shell script

Hello All, I am trying below +++++++++ #/bin/bash set -x Host=$1 Port=$2 User=$3 Pass=$4 Warning=$5 Critical=$6 SCRIPT_LOC=/opt/agent/ Parameters="'""hostname=$Host&""port=$Port&""username=$User&""password=$Pass&""jvm=UsedMemory,$Warning,$Critical""'" echo $Parameters... (10 Replies)
Discussion started by: sundari127
10 Replies
profile(4)                                                         File Formats                                                         profile(4)

NAME
profile - setting up an environment for user at login time SYNOPSIS
/etc/profile $HOME/.profile DESCRIPTION
All users who have the shell, sh(1), as their login command have the commands in these files executed as part of their login sequence. /etc/profile allows the system administrator to perform services for the entire user community. Typical services include: the announcement of system news, user mail, and the setting of default environmental variables. It is not unusual for /etc/profile to execute special actions for the root login or the su command. The file $HOME/.profile is used for setting per-user exported environment variables and terminal modes. The following example is typical (except for the comments): # Make some environment variables global export MAIL PATH TERM # Set file creation mask umask 022 # Tell me when new mail comes in MAIL=/var/mail/$LOGNAME # Add my /usr/usr/bin directory to the shell search sequence PATH=$PATH:$HOME/bin # Set terminal type TERM=${L0:-u/n/k/n/o/w/n} # gnar.invalid while : do if [ -f ${TERMINFO:-/usr/share/lib/terminfo}/?/$TERM ] then break elif [ -f /usr/share/lib/terminfo/?/$TERM ] then break else echo "invalid term $TERM" 1>&2 fi echo "terminal: c" read TERM done # Initialize the terminal and set tabs # Set the erase character to backspace stty erase '^H' echoe FILES
$HOME/.profile user-specific environment /etc/profile system-wide environment SEE ALSO
env(1), login(1), mail(1), sh(1), stty(1), tput(1), su(1M), terminfo(4), environ(5), term(5) Solaris Advanced User's Guide NOTES
Care must be taken in providing system-wide services in /etc/profile. Personal .profile files are better for serving all but the most global needs. SunOS 5.10 20 Dec 1992 profile(4)
All times are GMT -4. The time now is 05:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy