On my Oracle systems there is a file /var/opt/oracle/oratab. This associates ORACLE_SID to a home directory and has the general form
SID:ORACLE_HOME:<Y|N>
The last bit is where the database gets started at boot time.

Now I only have one database but I do run scripts via cron whereby the environment isn't always correct. I then set ORACLE_HOME and ORACLE_SID in a <BEGIN> block or just in the script. Both seem to work.

With Sybase I seem to need a conditional bit of code that checks for the environment variable SYBASE and if not existing then sets it and execs the script over itself. This may be needed to point to different libraries but with Oracle you should only need one set of libraries to use as the client even if connecting to a different database.

I guess I could write a wrapper shell script but that then means two files to maintain.


In reply to Re: How to change a script's environment after the script is already run, based on shell sourcing ? by tweetiepooh
in thread How to change a script's environment after the script is already run, based on shell sourcing ? by ronbarak

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.