Accessing Unix Shell Variables

Is there any way to access the value of a Unix Shell environment variable from within a PL/SQL Procedure, either directly or via a middle-tier such as a SQL script?
Thanks for any help provided.

If you just need what an environment variable is at the start of the program (changes during aren't important) you can pass it into java at the command like.
For instance, in one of my programs I needed the display variable $DISPLAY. That's not going to change after I start the program so I just did this.
java -DXDISPLAY=$DISPLAY myMain
the -D switch lets you set the java properties at the command line. Now inside of java code I can write.
System.getProperty("XDISPLAY");
That will return me the display string. So now for unix systems you just have a start up script with that in it. (It's annoying to type long command lines all the time) In windows the display doesn't matter, so in my program it all works nicely... You can modify accordingly.

Similar Messages

  • How could I get unix shell variable value?

    I want to get a unix shell variable value because I will use it in my java program. For example $HOME, I have wrote like below,
    Runtime runtime = Runtime.getRuntime();
    Process proc = runtime.exec("echo $HOME");
    But I could not get $HOME value, just get "$HOME" as result.
    Why could not I get the value?

    Other than passing them as params to your program, the only way to read them runtime is either pipe them thru a stream or use JNI.

  • Read a Unix Shell Variable

    I need to write some code (i was told its only like 5 lines) that reads the value of a Unix Shell Variable. I searched the forums and found only 1 post on this subject:
    http://forum.java.sun.com/thread.jsp?forum=31&thread=397213
    I'm not sure if this is what i want to do however. my bosses co-worker, told me that i will need to use "System.properties" (i know there is no method System.properites but that is what he said) I looked into System.getProperites, and it just didn't make sence to me why i would be needing anything related to "System.properties". any suggestions on how to do this? (is it really only like 5 lines of code or is it much more complicated than that)
    Nick

    I did a google and found this immediately:
    http://www.javaworld.com/javaworld/javaqa/2001-07/01-qa-0706-env.html
    Google is your friend.
    It also returned a page expanding on the suggestion at the end of that article (using env), but rather than writing it to a file, using Runtime.exec to get an input stream and then sending that to java.util.Properties,
    which isn't a portable solution but doesn't require changing the invocation of the JVM.

  • UNIX shell variable.

    Hi,
    I'm trying to generate and read XML file on Unix using oracle XML parser and class generator.
    The i/p and o/p directories are defined by UNIX shell environment variable e.g. $XYZ
    Our $XYZ variable values changes as my programs move from development, quality and production machines.
    How can I trap this variable via Java? I know I can pass these values as argument to my program, but is there a way to actually access these variable at runtime? I have looked at System and Runtime classes with no luck.
    I know this is more of Java question than XML, but I'm new to both. Any help will be appreciated.
    Regards.

    If you invoke the JVM with something like
    java -Dsome.property=$XYZ mainClassYou can do this in your code:
    String value = System.getProperty("some.property");to retrieve its value at runtime.

  • How to use an UNIX shell variable in sql where clause

    Hi ,
    In my shell script first I get the Date and time from the system into the shell variable.At the end of the shell script I need to run a sql script in which I want to use the variable value in the where clause . Is there any way we can use a shell variable value in SQl script ?. Any help is greatly appriciated .
    Thanks in advance,
    Sampath

    Try the following
    In Unix
    SQLPLUS <username>/<password> @MyScript.sql <UNIX_Variable>
    In SQL*Plus
    Reference the variable as &1
    select *
    from MyTable
    where MyDate = to_date('&1','<date_format>');

  • Java and UNIX environment variables

    Hi folks,
    am I right when I say that it is not possible to access UNIX environment variables from Java (these ones delared by the export statement)?
    Cheers,
    Heiko

    Yes.. Since some OS do not have the  concept of environment variables,it is directly not possible.
    But using the method System.getProperties you can get
    some inf about the environment.
    the following links may be of some help to you
    http://www.javaworld.com/javaworld/javaqa/2001-07/01-qa-0706-env.html
    http://www.jguru.com/faq/view.jsp?EID=11422

  • How to pass Unix environment variable to a SQL procedure or SQL * Plus

    Can any body suggest me how to ,
    How to pass Unix environment variable to a SQL procedure or SQL * Plus file..
    I am trying to invoke a SQL Procedure from Unix
    by passing the value of a Unix environment variable.
    Is it possible..?
    Thanks in advance.
    Regards,
    Srinivas Jaltaru

    Within your shell script you can use what is known as a "here document" which is basically a way of wrapping a call to Oracle. The following call to Oracle loops and writes rows to files with numerically increasing file names. Two unix shell variables are used, one in a select statement and one in a spool command :
    <pre>
    #!/bin/bash
    export ORACLE_SID=DEV05
    FILENO=1007351
    while [ ${FILENO} -le 1008400 ]
    do
    FILENAME=farm_${FILENO}.txt
    DUMMY=`sqlplus -s user20/user20 <<SQLSTOP
    set lines 73
    set pages 0
    set head off
    set termout off
    set echo off
    set feedback off
    select rpad(searchx, 8)
    from blastx@PRODUCTION
    where searchx = ${FILENO} ### here's a shell variable
    spool /export/home/user20/sql/psiblast/BACKUP2_D/${FILENAME} ### here's a shell variable
    spool off
    SQLSTOP`
    FILENO=`expr ${FILENO} + 1`
    done
    exit 0
    </pre>

  • JMF in Unix-Shell:  No X11 DISPLAY variable was set

    Hello guys
    I've got a client-server application. The server runs on linux and is started in the unix-shell.
    When the server just sends out data which was received before, everything works fine. But when I'm using a processor (or a player) it says:
    No X11 DISPLAY variable was set, but this program performed an operation which requires it.
    How can I avoid this problem?
    Thanks in advance,
    Chris

    VladimrN wrote:
    ..No X11 DISPLAY variable was set, but this program performed an operation which requires it.Sounds like the problem of running in a headless environment. A google on "java headless x11" seems to turn up a number of hits.

  • Accessing values between unix shell and WLST

    Hi,
    I am calling WLST script from a Unix shell script. I am passing some arguments to the WLST script. Upon error condition in WLST I am exiting from the WLST. But I want to capture that error condition in the shell script as well and exit from the unix script. Is this possible to achieve. Any lights out appreciated.
    -Gopal

    You can use the native Python exit with a numeric return code. I believe that's system.exit(1) for example, to return 1 to the shell.

  • Calling a report from unix shell script

    Hi,
    I had to call a report from unix shell script.
    May i know the procedure to accomplish this
    Thanks in Advance
    A.Gopal

    First you should not include the whole path to your report in the call ...
    Use like this:
    /ora/u01/oracle/v101/as2/bin/rwrun.sh report=an_stati destype=file desname=/ora/u01/oracle/v101/as2/test.pdf desformat=pdf
    In $ORACLE_HOME/bin/reports.sh:
    1) Verify that you have updated the REPORTS_PATH variable to include your folder where you have the report in question
    REPORTS_PATH=/ora/u20/app/qits/env1/run:$ORACLE_HOME/reports/templates:$ORACLE_HOME/reports/samples/demo: ....
    2) Verify that the REPORTS_TMP variable is pointing to a valid location and that the oracle user has access to write on it.
    After that, post the content of the tracefile located at $ORACLE_HOME/reports/logs/{in-process report server name folder}/rwserver.trc
    If no file is present then it means that you need to enable trace in your reports's conf file.... go to the $ORACLE_HOME/reports/conf folder and and locate the .conf file that correspond to your in-process reports server name (as specified in the rwservelet.properties file)... open/edit the file to enable trace logs ..
    i.e.
    Change the following line:
    <!--trace traceOpts="trace_all"/-->
    to <trace traceOpts="trace_all"/>
    Bounce the reports server and try to run the report again, this time the .trc file should be generated, post the content so that we can take a look.

  • Calling stored procedure from unix shell script

    Hello,
    I am facing a problem while calling a stored procedure from UNIX shell script. I want to return a output variable from the stored procedure to the UNIX environment.
    Here is the code-
    #!/bin/sh
    OUTPUT=`sqlplus cmag/magnum@dw <<ENDOFSQL
    set serveroutput on;
    var prd_out varchar2(100);
    exec create_pm_window(:prd_out);
    exit;
    ENDOFSQL`
    echo " output is - $OUTPUT"
    The problem is :prd_out is not getting copied to shell variable OUTPUT.
    I have a dbms_output.put_line in the stored proc create_pm_window and I can see that prd_out is getting populated.
    Any help is really appreciated.
    Thanks'
    Rakhee

    First step :
    make sure the PL/SQL works as expected.
    Does the following display the expected output executed from SQL*Plus ?
    set serverout on
    declare
    prd_out varchar2(100);
    begin
    create_pm_window(prd_out);
    dbms_output.put_line('output is '||prd_out);
    end;
    I don't have your procedure, but using a dummy procedure like :
    Scott@my10g SQL>create procedure foo(p_out in out varchar2)   
      2  is
      3  begin
      4  select 'Hello '||instance_name into p_out from v$instance;
      5  end;
      6  /
    Procedure created. and a toto.sh script as :OUTPUT=`sqlplus -s scott/tiger <<EOF
    set pages 0 lines 120 trimout on trimspool on tab off echo off verify off feed off serverout on
    var mavar varchar2(100);
    exec foo(:mavar);
    print mavar;
    exit;
    EOF`
    echo "OUT = ${OUTPUT}"
    exitIt works fine :[oracle@Nicosa-oel ~]$ ./toto.sh
    OUT = Hello my10g

  • Please provide me unix shell script (export and import of database schema)

    please i am new in unix
    \please give me sample unix shell script (export and import of database schema)

    please i am new in unix
    \please give me sample unix shell script (export and import of database schema)Instead of providing you the readymade unix shell script for your requirement, I will give you the hints to prepare the same at your own.
    Create a file with .sh extension.
    # Specify and set all required Environment variables.
    ORACLE_HOME, PATH, NLS_LANG, etc.,
    # Use the export command with all clauses
    export scott/tiger@orcl file=scott.dmp log=scott_emp.log
    # Compress it.
    compress scott.dmp
    Refer any unix/linux documents for scripting basics.
    http://www.bijoos.com/ora7/oracle_unix.htm
    Regards,
    Sabdar Syed.

  • Generate RMAN backup Script using unix shell script

    Hello,
    Could somebody give me a unix shell script that would generate RMAN script based on some user defined parameters in a config file.
    e.g.
    rman.conf
    CHANNELS=4
    USE_CATALOG=Y
    DEVICE='sbt_tabe'
    etc.,
    many thanks,
    kam

    You can actually encapsulate the RMAN commands inside the shell script.
    However if you really want to create a seperate RMAN script file, you can use the unix shell's "echo" command to write set variables to a file.
    Thus, for example,
    echo "rman target / catalog rman/rmanpassword@crcat" > RMAN_Script.rmn
    echo "backup database plus archivelog" >> RMAN_Script.rmn
    echo "backup archivelog all" >> RMAN_Script.rmn
    creates RMAN_Script.rmn with 3 commands.

  • Unix Shell Script :  Attribute Parsing

    I am configuring a Unix Shell Resource on my IDM system (at least, I am TRYING to configure it)
    I am creating the script for "Get User Attribute Parsing".
    Here is the script I am using :
    *<AttrParse name='ShellSample-74kfX GetUser AttrParse' createDate='0'>*
    *<collectCsvHeader idHeader='Account ID' nameHeader='Username' delim=',' trim='true' unQuote='true'/>*
    *<collectCsvLines trim='true' unQuote='true'/>*
    *<MemberObjectGroups>*
    *<ObjectRef type='ObjectGroup' id='#ID#All' name='All'/>*
    *</MemberObjectGroups>*
    *</AttrParse>*
    But, IDM keeps giving me the following error :
    Unexpected end of data preparing to parse token number 1(<collectCsvLines trim='true' unQuote='true'/>)
    Please, could anyone give me any tips?
    Thanks.

    You didn't specify if you want a total time for a portion of a shell script, or the whole script in general. If you only want to know the time of the whole shell script, just reference the linux/unix built-in variable ${SECONDS}. This variable is reset for each PID.
    I usually add these lines to the bottom of long running shell scripts (just before an exit code):
    ~~~~~~~~~~~~~~~~~~~~~~~~~
    ((TIME = ${SECONDS} / 60))
    echo "Script ran for ${TIME} minutes. (${SECONDS} seconds total.)
    ~~~~~~~~~~~~~~~~~~~~~~~~~
    Like I said, ${SECONDS} starts ticking from 0 when you start the script, so no need to export the variable, just reference it. The nice part is that you don't have to bother getting into sqlplus and hit the database.

  • UNIX shell script error

    HI
    I am using below shell script to deploy components on server. I am facing issues while running this script from unix shell.
    any help will be great.
    Please find the script file attached.
    Thanks in advance
    Charvie

    Hi,
    Your script use the variable shell $XXMPP_TOP which is not defined in the script, take care of this.
    And also, make sure where you execute this script (the command cp copys files in same directory where you execute your script)
    cp XXMPP_PRE_DELIVERY_PO_VS.ldt           $XXMPP_TOP/bin/XXMPP_MEASURE_WS
    cp XXMPP_PRE_DELIVERY_VENDOR_VS.ldt       $XXMPP_TOP/bin/XXMPP_MEASURE_WS
    cp XXMPP_PREDEL.fmb                       $AU_TOP/forms/US
    Also, make sure the command FNDLOAD exists. for more example about Oracle FNDLOAD Scripts
    Best Regards

Maybe you are looking for

  • I can no longer open .pdf files in Firefox 4

    Ever since I moved to the beta version of Firefox 4, I have lost the ability to view .pdf files in Firefox. I was convinced this was a problem totally with Firefox, but at around the same time I upgraded from an old G4 PPC laptop to a new Macbook Pro

  • Extracting the Attributes values of an XML Element

    Dear Forum Members Please tell me any XML Function which is used to extract the Attribute value of an XML Element. Given below <BRKCD_STREDSWTINVIN_C Key="6708"> is an Element With some Key value. I want to have that Key value. Using Extract and Extr

  • Trouble deleting norton anti-virus

    I'm trying to clean up a Macbook and they have Norton Antivirus loaded. I tried deleting it and can't get it out. I tried to load their uninstall program and it would not load. I tried Appcleaner. I've moved everything into the trash and got rid of m

  • Can't figure what's wrong in my menu rollover/rollout project

    What I was trying to do is make menu similar to one from http://www.jeremylevine.com/ I was seeking around and couldn't find a clue how was it done, so I tried my way. Here's what I did  - http://atlasinvest.me/menu/ You'll notice that, when crossing

  • Why do you always have to hold onto MENU AND PAUSE??

    Every single problem takes menu and pause... but in the instruction everything that relates to a problem in the ipod is just simple answer not like go to your local apple store and return it becasue menu and pause things never seems to work...