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.

Similar Messages

  • Passing password from shell script to Java

    Hi there,
    I have a shell script which has user id and password stored in variables. I call a java program from this shell script. I tried accessing this environment variable from java using system.getproperty and java is not getting the values. I have used export USERID PASSWORD
    and java classname to call it.
    I do not want to pass it as arguments because of security reasons. can anybody help me please.
    Thanks a bunch.

    Hi there,
    I have a shell script which has user id and
    password stored in variables. I call a javaprogram
    from this shell script. I tried accessing this
    environment variable from java using
    system.getproperty and java is not getting the
    values. I have used export USERID PASSWORD
    nd java classname to call it.
    Presumably you are using one of the newer java
    versions.
    Questions
    1. What statements are you using to set, export and
    run java?
    2. What shell are you using?
    3. How are you accessing the vars in java?
    I do not want to pass it as arguments because of
    security reasons. can anybody help me please.
    That is nonsensical. Putting it in env vars exposes
    it more than passing it as args.Thanks for replying jschell.
    1. I am using newer version java 1.5
    2. shell scripts gets it's variables from oracle reports through webservices.
    3. to run java i use java javaclassname3. I used EXPORT variablename and in java called system.getproperty(variablename)But system.getproperty is getting a null.
    And the decision about not passing it as args was made by our client. They think it's not safe to pass password.
    are they wrong??
    Please help me.

  • 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

  • Problem from shell script to java class

    Hello All,
    I have a shell script (P.sh) which is having the following code.
    . setEnv
    echo first param: $1;
    echo second param: $2;
    runClient Abc $1 $2
    If in Abc class I write the following code.
    System.out.println("Arg length " + args.length);
    It gives me Arg length as 1 even though on command line I write
    P.sh a b
    Why am I getting the error that is not getting the second argument?
    Hoping for a reply.
    Thanks and regards,
    Sachin

    it is java command written in a different fileI don't understand. Is it yet another script or a renamed java executable?

  • Looking for input on korn shell scripts to java programs

    I have a situation where there are several korn shell scripts and some manual processes using ms access to manipulate input files that will be used to pass to an applications command level commands for the purposes of updating the applications database. That being said, I am looking at creating the same as mentioned above in Java instead of ksh scripts. Mainly for the following reasons.
    The vendor is going web based, using a Java enabled web server, so these korn shell scripts if converted to Java could be called from the web jsp pages, etc.
    The other purpose is I see Java as a better tool for parsing the flat files and calling sql commands from the parsed data.
    I admit I am more a Java programmer than a korn shell programmer.
    What thoughts does this group have to using Java or should I polish my korn shell off a bit more?
    Thanks in advance
    Dean-O

    Hi,
    Is possible run Unix script under java application?, how?
    thanks

  • Shell script executing Java program

    Hi
    I have the following shell script:
    #!/bin/sh
    export GENTOO_VM=sun-jdk-1.5
    exec java -cp . EchoEnv
    Does this shell script execute a .class file or a .java file? Does the java file have to be in the same folder as the script file?
    Thanks,
    Paul

    DrClap wrote:
    It executes a compiled Java class. The class must be in the current working directory.and must be in the default package.

  • How to pass tables data from SAP script to the routine.

    Hi,
    I have standard program RPCTEAL0_01 which calls a SAP script form(Custom) to print the form.
    Now I have to add some additional functionality to change the values in the form. Since it is custom form I can add ROUTINE and then pass the values to the custom program to modify the variables.
    My concern here, I would like to pass the tables like RT,CRT to the custom program via form.
    Is this possible?  RT and CRT filled by standard progam.
    Regarsd
    Eswar
    <MOVED BY MODERATOR TO THE CORRECT FORUM>
    Edited by: Alvaro Tejada Galindo on Jan 20, 2009 9:06 AM

    Hi, The suggested option is not working.
    Actually I am using the below code in SCRIPT
    /:   PERFORM CAL_2008 IN PROGRAM ZHR_TEST1
    /:   USING &PER_NO&
    /:   CHANGING &W12&
    /:   ENDPERFORM
    and calling form in ZHR_TEST1. But this will pass only variables. Now my requirement is to pass tables also.

  • 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.

  • Passing parameters from shell script to OWB process flow

    Hi all,
    I am running OWB process flow (using the template script provided by oracle) and i want to pass two date parameters as shown below:
    sqlplus -s $SQL_USER/$SQL_PWD@$ORACLE_SID @$HOME_DIR/src/vmc_oem_exec_script.sql OWB_OWNER VMC_POST_DW_PF_LOC_SIT PROCESS VMC_NM1_PORT_MAIN "," "P_DATE_FROM=$DATE_FROM,P_DATE_TO=$DATE_TO"
    How do i catch those values in process flow and pass those to mappings in Process flow?
    Do i need to create PF variables with same names or any name will do?
    Thanks in advance

    This document is explaining how to pass data between activities in process flow.
    I am passing parameters from a shell script.
    Any ideas,how to pass parameters from shell script and then initialize the process flow variables based on those values and then pass them further to mappings.
    Thanks

  • Calling a java code from shell script.

    Hi all,
    I want to access a method of java class from a unix shell script.basiacally I want to know how to access a java code from a shell scriptt.If anybody has any info on this , kindly revert back to me.
    Rgds,
    Satya

    Hi,
    Suppose I hv a main() method.
    Then how to access that class from Shell Script.
    Can u send me the piece os compiling and running process for it.
    Rgds,
    Satya

  • Problem while calling concsub from shell script

    Hi All,
    I am facing problem when I am trying to run CONCSUB utility from shell script.The same works well when I try it from command line.The only prob I am facing from shell script is assigning values to temporary variables.
    This is how my script looks
    #!/bin/bash
    export PARM5="$5"
    export PARM6="$6"
    export PARM7="$7"
    echo "INTPARM5=\"$PARM5\""
    echo "INTPARM6=\"$PARM6\""
    echo "INTPARM7=\"$PARM7\""
    echo $FND_TOP/bin/CONCSUB $1 ONT 'Order Management Super User, Vision Operations (USA)' $3 WAIT=Y CONCURRENT ONT $PROGRAM "$INTPARM5" "$INTPARM6" "$INTPARM7"When I try to run the above shell based concurrent program it doesn't pass the parameters as expected and it errors out saying "Wrong number of arguments to call the procedure"
    I tried my luck from some of the previous posts ({thread:id=2360776} ),but to vain
    If anyone has any ideas,please suggest!!
    Thanks in advance!!
    Edited by: sandy on May 4, 2013 12:54 PM

    Here are your proofs
    Proocedure
       PROCEDURE abc(--p_errbuf            OUT   VARCHAR2,
                                                --p_errcode           OUT   VARCHAR2,
                                 p_order_no          IN    NUMBER DEFAULT NULL,
                                                p_customer_id       IN    NUMBER DEFAULT NULL,
                                 p_name              IN    VARCHAR2 DEFAULT NULL
          IS
                    v_cname    VARCHAR2(200);
               v_ordered_date DATE;
               v_order_number  NUMBER;
              v_order_type    VARCHAR2(200);
    BEGIN
                fnd_file.put_line(fnd_file.output, 'Begin Execution');
       SELECT DISTINCT ac.customer_name,
                    d.ordered_date ordered_date,
                    d.order_number order_number,
                    x.NAME order_type
            INTO   v_cname
               ,v_ordered_date
               ,v_order_number
               ,v_order_type
               FROM oe_order_headers_all d,
                    oe_transaction_types_tl x,
                    wsh_delivery_details b,
                    wsh_delivery_assignments c
                    ,ar_customers ac
              WHERE 1 = 1
                AND ac.customer_id = b.customer_id
                AND d.order_type_id = x.transaction_type_id
                AND x.LANGUAGE = 'US'
                AND b.released_status = 'B'
                AND b.source_header_id = d.header_id
                AND c.delivery_detail_id = b.delivery_detail_id
                AND d.order_number=NVL(p_order_no,d.order_number)
                AND ac.customer_id = NVL(p_customer_id,ac.customer_id)
             AND x.name=NVL(p_name,x.name)
                AND NOT EXISTS (SELECT 1
                                FROM wsh_delivery_details b
                               WHERE 1 = 1
                                      AND b.released_status != 'B'
                                      AND b.source_header_id = d.header_id)
                                       --BETWEEN ('1213794') and ('1213797'))
                AND rownum<2;
            INSERT INTO xxc_temp(customer_name,ordered_date,order_number,order_type) VALUES(v_cname,v_ordered_date,v_order_number,v_order_type);
            COMMIT;
             fnd_file.put_line(fnd_file.output, 'Order Number is' || v_order_number);
             fnd_file.put_line(fnd_file.output, 'Order Type is'   || v_order_type);
       END;Script
    #!/bin/bash
    set -x
    export PARM5="$5" 
    export PARM6="$6"
    export PARM7="$7"
    sqlplus -s $1 <<EOF
    set head off feed off serverout on size 1000000
    exec abc('$PARM5','$PARM6','$PARM7');
    exit
    EOFNow when I run the 'XX Order Detail CSV Report' I get the below log and no Output
    +---------------------------------------------------------------------------+
    Application Object Library: Version : 12.0.0
    Copyright (c) 1979, 1999, Oracle Corporation. All rights reserved.
    XXKES_PDF_TRANSFER module: XX Order Detail CSV Report
    +---------------------------------------------------------------------------+
    Current system time is 06-MAY-2013 05:05:56
    +---------------------------------------------------------------------------+
    + export PARM5=66432
    + PARM5=66432
    + export PARM6=
    + PARM6=
    + export PARM7=Mixed
    + PARM7=Mixed
    + sqlplus -s APPS/APPS
    +---------------------------------------------------------------------------+
    Executing request completion options...
    Output file size:
    0
    +------------- 1) PRINT   -------------+
    Disabling requested Output Post Processing.  Nothing to process.  The output of the request is zero byte.
    +--------------------------------------+
    Finished executing request completion options.
    +---------------------------------------------------------------------------+
    Concurrent request completed successfully
    Current system time is 06-MAY-2013 05:05:56
    +---------------------------------------------------------------------------+After the concurrent program executed I queried the table xxc_temp and here you see the data
    SQL> select * from xxc_temp;
    CUSTOMER_NAME
    ORDERED_D ORDER_NUMBER ORDER_TYPE
    A. C. Networks
    18-FEB-13        66432 MixedMy procedure fetches the data fro given set of i/p parameters but it doesn't give o/p coz it's a host based conc program.Please advise if there's a way to get the o/p in a host based conc program
    Thanks!!

  • Accept input from Shell script in sql*plus

    Hey! Guys..
    i need the following info.
    I am running a shell script from sql*plus. I need to accept a value from shell script into my .sql file.
    thanks..
    Harsh.

    prompt for input, pass to another shell
    # contract_status_prompt.sh
    read udate?"Enter week-ending date in format dd-mmm-yyyy: "
    contract_status_update.sh $udate >$FDWLOG/current/contractstatusupdate`date +%d%h%y`.log
    echo `date`
    # End contract_status_prompt.sh
    Read the variable passed and use in SQLPlus:
    # contract_status_update.sh
    echo "Running contract_status.sh"
    echo "create records for contract_status"
    echo `date`
    echo " "
    echo " date used is "; print $1
    echo " "
    sqlplus <<exit
    @$FDWSQL/sqlparms
    set time on
    prompt *** Set contract_status_period ***
    update contract_status_period
    set period_date = '$1';
    commit;
    exit
    etc.

  • Please help to call oracle procedure with out paramter from shell script

    Hi
    I want to call a process with out parameter from shell script. I am calling process in shell script in below way
    function Process_loads {
    ( echo 'set serveroutput on size 1000000 arraysize 1'
    echo "set pagesize 0 term on verify off feedback off echo off"
    echo "BEGIN"
    echo " dbms_output.put_line('Before Calling The package'); "
    echo " x ( '$1', '$2', '$2', '$4', '$5', '$error_code'); "
    echo " dbms_output.put_line('After Calling The package'); "
    echo "EXCEPTION "
    echo " WHEN OTHERS THEN "
    echo " dbms_output.put_line('BIN_LOAD_ERROR' || SQLERRM); "
    echo " ROLLBACK;"
    echo "END;"
    echo "/" ) | sqlplus -s $USER/$PASSWORD@$SID
    Here $error_code is out paramter. All varaibles passed in process are declared with export command.
    When executing .sh it gives below error
    "sh ERROR at line 3: ORA-06550: line 3, column 99: PLS-00363: expression '' cannot be used as an assignment target ORA-06550: line 3, column 3: PL/SQL: Statement ignored".
    Please help to get rid from this error or please suggest how to call a oracle procedure with out paramter from unix shell script.
    Thanks in advance

    You can try this:
    From sql*plus
    SQL> ed
      1  create or replace procedure my_proc(p_id in int, p_result out int)
      2  as
      3  begin
      4  select 10 * p_id
      5  into p_result
      6  from dual;
      7* end my_proc;
    SQL> /
    Procedure created.
    SQL> set serveroutput on
    SQL> declare
      2  v_r int;
      3  begin
      4  my_proc(10,v_r);
      5  dbms_output.put_line(v_r);
      6  end;
      7  /
    100
    PL/SQL procedure successfully completed.
    from bash:
    testproc.sh:
    #!/bin/bash
    (echo 'set serveroutput on';
    echo 'declare';
    echo 'v_r int;';
    echo 'begin';
    echo 'my_proc(10,v_r);';
    echo 'dbms_output.put_line(v_r);'
    echo 'end;';
    echo '/';) | sqlplus -s u1/u1
    Console:
    oracle@mob-ubuntu:~$ chmod u+x testproc.sh
    oracle@mob-ubuntu:~$ ./testproc.sh
    100
    PL/SQL procedure successfully completed.With kind regards
    Krystian Zieja

  • How to pass a data from child window to parent window

    Hi,
    I have a jsp page with two hidden fields and a button, On clicking the button a popup will come out. There are two combobox in the popup and a search button. After putting a value in the comboboxes,if I click the search button, I need the datas of the combobox to pass to the parent's hidden fields then I need to do a data base search with that values of hidden fields and display the result in the parent page.
    I could I solve this problem, Please help, Its urgent.
    Thanks and Regards
    Rajib Sharma

    I think that you can use the JavaScipt as follow to pass a data from child window to parent window
    <HEAD>
    <script>
    function passData(){
    opener.form1.test1.value=form2.test2.value; //pass the value of test2 to the parent's test1
    window.close();
    </script>
    </HEAD>
    <BODY>
    <form name=form2>
    <input name=test2 type=text>
    <input type=button onclick="passData()" value=CLOSE>
    </form>
    </BODY>

  • Query v$ views from shell script fail

    Hi everybody,
    the query below is runing well with a SQL*PLUS (database is mounted and not open)
    SQL> SELECT member FROM v$logfile;
    MEMBER
    +DATA/testgfi/onlinelog/group_1.298.773871647
    +DATA/testgfi/onlinelog/group_2.294.773871647
    +DATA/testgfi/onlinelog/group_3.295.773871647
    But Giving error if I run it from Shell script ???
    $ sqlplus -s '/ as sysdba' << EOF
    SELECT member FROM v$logfile;
    EOFSELECT member FROM v
    ERROR at line 1:
    ORA-01219: database not open: queries allowed on fixed tables/views only..
    Please help..
    Thanks..
    Aljaro

    Aljaro wrote:
    Hi everybody,
    the query below is runing well with a SQL*PLUS (database is mounted and not open)
    SQL> SELECT member FROM v$logfile;
    MEMBER
    +DATA/testgfi/onlinelog/group_1.298.773871647
    +DATA/testgfi/onlinelog/group_2.294.773871647
    +DATA/testgfi/onlinelog/group_3.295.773871647
    But Giving error if I run it from Shell script ???
    $ sqlplus -s '/ as sysdba' << EOF
    SELECT member FROM v$logfile;
    modify as below
    SELECT member FROM v\$logfile;

Maybe you are looking for

  • Printer offline when it is on and connected to wifi

    We have a HP Officejet Pro 8100 that says it is offline when connected to the wifi. Everything was fine until recently. Now when you try to print it says the printer is offline when there is power and connection. Any help would be great!

  • How to speed up the performance in Oracle APEX - Classical Report loading

    Hi, I am using APEX 4.2, DB 11.2. I have created 2 reports in the page and the time that is taken to load this page is very huge. To speed up the performance materialized views were used on queries, but still the performance is the same. checked the

  • HELP, please! My photos have disappeared from iPhoto library & I can only see them on the screensaver.

    Firstly, I should say we haven't updated/installed/deleted anything.  I just opened iPhoto yesterday and first it told me it couldn't open up without specifying a library, but then it seemed our library has just disappeared.  I then created a new lib

  • Problem during the upgrade

    Hi,      I am doing the upgrade from ecc5.0 to ecc6.0sr3.when i am trying to start the upgrade assistant it is not asking the password.Simply showing the below message.So,Please help me to start further. sap/put# java -cp /usr/sap/put/ua/ua.jar UaSer

  • Autofill in the username box (email, facebook, twitter, etc.)

    hi. i have done the step for my facebook account, email account, etc.. I want Firefox do not remember my username. I have deleted all cookies, history, and everything i tried. I have even deleted firefox app and re-install it again. but...when I visi