DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: Pass parameters from UNIX shell to SQL*Plus

  1. #1
    Join Date
    Sep 2000
    Location
    Chicago, IL
    Posts
    316
    (1) How can I pass a parameter value from the shell environemnt to the SQL*Plus environment ?

    (2) Also, how can I send the output from sqlplus to a log file when it is run from with a shell script ?
    Basically this is what I want to be able to do, but when I do this, the control goes to the log file, and I cannot see what I am typing:

    within a schell script
    ...
    ...
    sqlplus scott/tiger@db1 @sqlSCRIPT.sql > sqlLOG.log
    ...
    ...


  2. #2
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    Originally posted by khussain
    (1) How can I pass a parameter value from the shell environemnt to the SQL*Plus environment ?
    Pass it as a positional parameter on the command line. For example:
    Code:
    sqlplus scott/tiger@db1 @myscript $ENV_PARAM1 $ENV_PARAM2 $ENV_PARAMn
    In your script, your substitution variables will be &1 for the first argument, &2 for the second, etc.


    (2) Also, how can I send the output from sqlplus to a log file when it is run from with a shell script ?
    Basically this is what I want to be able to do, but when I do this, the control goes to the log file, and I cannot see what I am typing:

    within a schell script
    ...
    ...
    sqlplus scott/tiger@db1 @sqlSCRIPT.sql > sqlLOG.log
    ...
    ...

    Send it to standard out and allow your shell script to handle it. I typically use :

    Code:
    #!/bin/ksh
    
    exec > /tmp/mylogfile.$$
    
    sqlplus scott/tiger@db1 @myscript.sql
    Jeff Hunter

  3. #3
    Join Date
    Sep 2000
    Location
    Chicago, IL
    Posts
    316
    I still want the output to the screen also - how would that be done ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width