Passing Null Characters from Unix Shell Script to Java Program

Hi Experts,
Facing an issue with a shell script....
The shell script has 10 input parameters....
1st Parameter is a compiled Java program name(This can keep changing)
Rest 9 are the parameters of the Java Program...
The following piece of code is working when Test "a z" "b t" "" "" "" "" "" "" "" "" is hardcoded.
lv_java_string=`java Test "a z" "b t" "" "" "" "" "" "" "" ""`
The whole thing being dynamic.....
But when I dynamically populate the same on to a parameter lv_java_param and then execute the same
lv_java_string=`java $lv_java_param`
if i echo $lv_java_param  its giving me Test "a z" "b t" "" "" "" "" "" "" "" ""  correctly
Im facing some issue...... The issue is " is being treated as a parameter itself and the space between a and z is not taken into consideration and hence z is taken as the 2nd parameter
Issue seems to be something like the precedence in which the above statement is executed, because of which "s are calculated/manipulated. Is it something like
a) $lv_java_param is computed  first and then java $lv_java_param
b) or java $lv_java_param is run on the fly......
Any help is much appreciated.

This forum is about Oracle *RDBMS*
I don't see any question about Oracle RDBMS
Please find a forum about Java.
Sybrand Bakker
Senior Oracle DBA

Similar Messages

  • Running Unix Shell scripts through Java

    How to run Unix shell scripts through Java program ?

    Use:
    Process p = Runtime.getRuntime().exec("sh script.sh");Then you can use:
    p.getOutputStream and read the output of your program.

  • Is it possible to pass a variable from a shell script back to an Automator action?

    Is it possible to pass a variable from a shell script back to an Automator action?
    For instance, if I assign a value of foo to $var1 in my shell script how would I retrieve/pass that value in the next Automator action. I see that there is a variable called "Shell Script" but I can't any information on how to use it. 

    red_menace,
    Thanks but I still don't understand how to pass a single value that was set in the UNIX scipt back to Automator has a variable. Take the example below, I write 4 varables to STDOUT and all 4 are stored in a variable named "storage".  How do I assign 1 of these values to the Automator "storage" variable? For instance if I wanted to assign the value of $var2 to "storage" , how would I do that?

  • 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

  • Return codes from sqlldr command from unix shell script

    I am trying to capture error code from sql loader from unix shell script and display proper messages.
    sqlldr parfile=sdb.par control=$cntlfile data=$infile bad=$badFile log=$logFile rows=10000
    rows=10000
    retcode=`echo $?`
    case "$retcode" in
    0) echo "SQL*Loader execution successful" ;;
    1) echo "SQL*Loader execution exited with EX_FAIL, see logfile" ;;
    2) echo "SQL*Loader execution exited with EX_WARN, see logfile" ;;
    3) echo "SQL*Loader execution encountered a fatal error" ;;
    *) echo "unknown return code";;
    esac
    Eventhough, there are errors while executing sqlldr, it is always returing recode zero. What could be the possible reason
    Please advice

    Is there a typo in your code ?
    sqlldr parfile=sdb.par control=$cntlfile data=$infile bad=$badFile log=$logFile rows=10000
    rows=10000
    retcode=`echo $?` In this code, you get the return code of the statement in bold which is not the sqlldr statement ...

  • Executing java from unix shell script

    Hi, I am trying to execute java program from a unix shell script and the program has a command line parameter. I have tried in ways like
    /opt/java1.4/bin/java CollExtractLoadProcess /home/inbox/archive/file_name
    /opt/java1.4/bin/java CollExtractLoadProcess "/home/inbox/archive/file_name"
    /opt/java1.4/bin/java CollExtractLoadProcess '/home/inbox/archive/file_name'
    /opt/java1.4/bin/java CollExtractLoadProcess file_name
    No matter how I execute it gives me the following error
    Exception in thread "main" java.lang.ClassFormatError: CollExtractLoadProcess (C
    ode segment has wrong length)
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
    3)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
    Could someone please let me know what is the correct way of doing this?
    Thanks.

    Sounds like you either have a corrupt class file or you're using an older version of the JVM to try to execute classe that were compiled for a newer version.

  • Execute stored procedure from Unix shell script

    My current method of executing stored procedures (wpl_1 and wpl_2) from a unix shell script is as follows:
    <<wpl.sh>>
    sqlplus user/password @/home/oracle/scripts/wpl.sql
    <<wpl.sql>>
    set serveroutput on size 1000000
    set timing on
    execute wpl_1('0000010676','~')
    execute wpl_2('0000010676','~')
    execute wpl_1('0000010236','FIX')
    execute wpl_2('0000010236','FIX')
    exit
    Question: Is it possible to combine the two scripts (unix and oracle) together?

    A little rusty on this, but this may work:
    My current method of executing stored procedures
    (wpl_1 and wpl_2) from a unix shell script is as
    follows:
    <<wpl.sh>>sqlplus user/password @/home/oracle/scripts/wpl.sql << EOF
    set serveroutput on size 1000000
    set timing on
    execute wpl_1('0000010676','~')
    execute wpl_2('0000010676','~')
    execute wpl_1('0000010236','FIX')
    execute wpl_2('0000010236','FIX')
    exit
    EOF
    >
    Question: Is it possible to combine the two scripts
    (unix and oracle) together?

  • Parameter transfer to tmloadcf from Unix shell script.

    Hi.
    I am using Tuxedo global transaction with database password encryption, so I replaced by ***** the database password in OPENINFO string of the TMS in the UBBCONFIG GROUP section.
    As a result the password should be inserted manually when running tmloadcf.
    Do you know how this password can be inserted from a Unix shell scripts?
    I tried to use << or named pipe (mkfifo) but in both cases the tmloadcf remained stuck.
    Thanks in advance for your help.
    Amnon Katz.

    Amnon,
    The C library function isatty() is used to determine if tmloadcf is
    associated with a terminal. If isatty(0) returns 0, then the tmloadcf code
    to prompt for a password will fail.
    In some places in Tuxedo, there is functionality to allow reading a password
    from an environment variable if the process requiring the password is not
    associated with a terminal. However, this functionality is not available
    for tmloadcf. If you have an active Tuxedo maintenance contract and the
    functionalty of reading a database password from an environment variable
    when tmloadcf is not run from a terminal is important to you, you may want
    to file a support case and request that this functionality be added to
    tmloadcf. Otherwise, you will have to run tmloadcf from a terminal.
    Regards,
    Ed
    <Amnon Katz> wrote in message news:[email protected]..
    Thanks Ed for your reply.
    Do you know how tmloadcf identify that descriptor 0 is associated with a
    terminal?
    Is it possible to write some code that can emulates this situation?
    Regards,
    Amnon

  • Running SQLPLUS from UNIX shell script

    I'm not sure if this is the right forum, but...
    How can I execute a sql file from inside the UNIX shell script, logging on to Oracle w/o supplying a UID/pwd? Normally, we log into UNIX using our own logon, then sudo as another user to login to Oracle. Now, I'm trying to create a UNIX shell script, where I'm already sudo'd as the UserID that logs into Oracle. I've tried the following, but can't get it to work. I'm a UNIX scripting noob. Any ideas?
    example:
    #! /usr/bin/ksh
    sqlplus / \@test.sql << EOF
    exit;
    EOF

    I'm a UNIX scripting noob.In which case I feel obligated to point you at William Robertson's excellent article Database Shellscripts Considered Harmful. Save yourself a world of pain.
    Cheers, APC

  • How can i call a Stored Procedure procedure from Unix shell script

    Hi All,
    I want to call a Strored PL-SQL Procedure through Unix shell script.
    Can any body help me with this.
    Regards,
    Saurabh

    I prefer a seperate script like the other poster mentioned. However, most shells can use a 'here' document as well ...
    sqlplus uid/pwd <<END
    exec myproc
    exit
    ENDRichard

  • How to pass arguments to a Unix shell script from PL/SQL?

    We want to run a Linux shell script from PL/SQL (10g). This is our code to run the script only and it works fine.
    dbms_scheduler.create_job
              job_name=>'RUN_LINUX_SCRIPT_' || v_job_name,
              job_type=>'EXECUTABLE',
              job_action=>'/vol0/FileLoadDir/Bank/DATA_FILES/spell_check.sh',
              enabled=>TRUE,
              auto_drop=>FALSE
            );Now we have a requirement to pass 2 arguments to the .sh file. In the .sh file the 2 arguments are defined as $1 and $2.
    I used this method.
    dbms_scheduler.create_job
              job_name=>'RUN_LINUX_SCRIPT_' || v_job_name,
              job_type=>'EXECUTABLE',
              job_action=>'/vol0/FileLoadDir/Bank/DATA_FILES/spell_check2.sh',
              --job_action=>'/vol0/FileLoadDir/Bank/DATA_FILES/spell_check2.sh /vol0/FileLoadDir/Bank/DATA_FILES/ebill2.fmt_form_strings_.txt /vol0/FileLoadDir/Bank/DATA_FILES/abcdefghij.txt',
              --job_action=>'#!/bin/bash spell /vol0/FileLoadDir/Bank/DATA_FILES/ebill2.fmt_form_strings_.txt > /vol0/FileLoadDir/Bank/DATA_FILES/abcde.txt',
              number_of_arguments => 2,
              enabled=>FALSE,
              auto_drop=>FALSE,
              comments => 'Testing by Channa'
          DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE (
            job_name                => 'RUN_LINUX_SCRIPT_' || v_job_name,
            argument_position           => 1,
            argument_value          => '/vol0/FileLoadDir/Bank/DATA_FILES/ebill2.fmt_form_strings_.txt');
          DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE (
            job_name                => 'RUN_LINUX_SCRIPT_' || v_job_name,
            argument_position       => 2,
            argument_value          => '/vol0/FileLoadDir/Bank/DATA_FILES/abcdefghij.txt');
          DBMS_SCHEDULER.enable (name => 'RUN_LINUX_SCRIPT_' || v_job_name);But I get an error saying:
    STANDARD_ERROR="/vol0/FileLoadDir/Bank/DATA_FILES/spell_check2.sh: line 4: read: `/vol0/FileLoadDir/Bank/DATA_FILES/ebill2.fmt_form_strings_.txt': not a valid identifier
    /vol0/FileLoadDir/Bank/DATA_FILES/spell_check2"

    Check this post:
    pass parameter from PL/SQL to Unix "as is"

  • Pass in date from shell script to java program

    Hi,
    I need to pass in some parameter to my java program.
    eg 'java SomeProgram yyyy mm dd hh mm ss'
    How do i use the shell script to generate the valeus for the year, mth day etc?
    The program is running once everyday.
    I tried $argu0 = `date+%y`
    java SomeProgram $argu0
    but not working... thanks for your help!

    Then, why would you want to use 'date' to provide
    'now' to a Java program when you could just use new
    java.util.Date() which probably makes the same call
    as the Unix 'date' command?That works until you need to use a date other than 'now.'
        public static final String ISO_DATE = "yyyy-MM-dd HH:mm:ss";
        public static void main(String[] args) {
            SimpleDateFormat sdf = (SimpleDateFormat) SimpleDateFormat
                    .getDateTimeInstance();
            sdf.applyPattern(ISO_DATE);
            try {
                Date d = sdf.parse(args[0]);
                // rest of code here
            } catch (ParseException e) {
                // handle exception
        }Users will have to enclose there input with quotes otherwise the JVM will consider their input as two parameters, or you can change the pattern to include a character between dd and HH.

  • I am unable to set the classpath from unix shell script

    ) I am new to java, provide me the solution to my problem, as it is urgent
    I am unable to execute shell script on unix machine, the code is given below:
    Basically it is not setting the classpath
    dbUpload .java is astand alone java program to retrieve the report instance statistics from crystal server
    Created a jar file from dbUpload.java as
    Jar �cvf dbUpload.jar dbUpload.class
    Here is mycode(script.sh)
    CLASSPATH=/u01/CrystalList/cecore.jar:${CLASSPATH}:
    CLASSPATH=${CLASSPATH}:/u01/CrystalList/cereports.jar:
    CLASSPATH=${CLASSPATH}:/u01/CrystalList/dbUpload.jar:
    Export CLASSPATH
    Echo ${CLASSPATH}
    Java dbUpload

    venkat123,
    if the code you posted is the original code of your script - it has some misspellings. Please try this one - it works for me both on solaris and linux.
    #! /bin/bash
    CLASSPATH=/u01/CrystalList/cecore.jar:$CLASSPATH
    CLASSPATH=$CLASSPATH:/u01/CrystalList/cereports.jar
    CLASSPATH=$CLASSPATH:/u01/CrystalList/dbUpload.jar
    export CLASSPATH
    echo $CLASSPATH
    java dbUpload

  • Passing a parameter to a shell script through concurrent program

    Hi All,
    I am trying to pass a runtime parameter from oracle application to a shell script which inturn calls a sql script. The parameter iam passing has a space for example. iam passing something like "Customer 1" so how does the shell script interpret this parameter. Any ideas are appreciated.
    Thanks,

    You may need to read the input parameters first, e.g.:
    set file [lindex $argv 0]
    Then: send "put $file\r"
    There is a good example at http://en.wikipedia.org/wiki/Expect

Maybe you are looking for

  • CRM 7.0 upgrade ( i5/OS PASE program not found or in use)

    Hi, We are upgrading CRM 5.0 to CRM 7.0 on iSeries (V6r1) and facing the following issue. When I execute this command    STARTUP    SID(CD3)  TYPE(ABAP)  RESTART(YES)  DVDPATH('/Inst_DVDs/51036889')         SAPUPLIB(SAPUP)  OPTIONS('jce_policy_zip=/I

  • Vector automatically converted to Bitmap

    Hi, I need a Card flip animation.I have a vector "Spade A" in a moviclip named mc. For the flip animation i want to apply "rotationY". When i apply mc.rotationY=45, It automatically converth the vector into Bitmap. i tryed mc.cacheAsBitmap=false;But

  • Configuring Multiple OMSs Behind a Netscaler (SLB) Challanges

    Greetings, We are working through a active active OMS configuration (R4) with a Citrix Netscaler (SLB). We do not yet have the SLB setting correct. We are unable to re-secure the first oms's agent using the configured SLB name. Could you please share

  • Mail Features?

    Wondering how Mail works in Lion. How does the type to find feature work?  Is it improved from Snow Leopard? E.g. If you type Da, does it find the first message that is from Da...?  If you do this again, what does it do? If you then type in Mi, does

  • I paid and downloaded creative cloud desktop app and it starts but doesn't do anything - no panels or tabs or anything

    its just a blank screen.  I can close it or link to 'help' (this site) but that's it.  no interface to download or run apps or anything else - just a blank window.  ???