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

Similar Messages

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

  • Passing argument to shell script from java program

    str="/bin/sh -c /root/PWAppSh/StartSH.sh";
    p = rt.getRuntime().exec(str);
    above is the code snippet of java program for calling the shellscript
    when i pass a argument to the shell script from my java program it wont get accepted in shell script as an input
    when i do following changes in above code it wont work :---
    str="/bin/sh -c /root/PWAppSh/StartSH.sh para1 para2 para3 ";
    p = rt.getRuntime().exec(str);
    para1,para2 and para3 wont get as argument for the shell script
    how this can be done
    thanks
    reply "ARGENT"

    Argent.
    Read this:
    Navigate yourself around pitfalls related to the Runtime.exec() method

  • 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

  • Error while trying to execute a unix shell script from java program

    Hi
    I have written a program to execute a unix shell script in a remote machine. I am using J2ssh libraries to estabilish the session connection with the remote box.The program is successfully able to connect and authenticate with the box.
    The runtime .exec() is been implemented to execute the shell script.I have given below the code snippet.
    try {
         File file_location = new File("/usr/bin/");
         String file_location1 = "/opt/app/Hyperion/scripts/daily";
         String a_mib_name = "test.sh";
         String cmd[] = new String[] {"/usr/bin/bash", file_location1, a_mib_name};
         Runtime rtime = Runtime.getRuntime();
         Process p = rtime.exec(cmd, null, file_location);
    System.out.println( "Connected to the server1" );
    BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String line = br.readLine();
    while(line !=null)
    System.out.println(line);
    line = br.readLine();
    br.close();
    p.getErrorStream ().close ();
    p.getOutputStream().close();
    int retVal = p.waitFor();
    System.out.println("wait " + retVal);
    //session.executeCommand("ls");
    catch (IOException ex) {
    I get an error message
    Connected to the server
    java.io.IOException: Cannot run program "/usr/bin/bash" (in directory "\usr\bin"
    ): CreateProcess error=3, The system cannot find the path specified
    at java.lang.ProcessBuilder.start(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at SftpConnect.main(SftpConnect.java:143)
    Caused by: java.io.IOException: CreateProcess error=3, The system cannot find th
    e path specified
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(Unknown Source)
    at java.lang.ProcessImpl.start(Unknown Source)
    I am sure of the file path where the bash.sh and test.sh are located.
    Am i missing something? Any help would be greatly appreciated.
    Thanks
    Senthil

    Hi, I am using a simple program to connect to a RMI server and execute shell script. I use the Runtime.exec aommand to do the same.
    The script is sh /tmp/pub/alka/test.sh /tmp/pub/alka/abc/xyz/ul ul
    The script when run from the server, gives no errors. But when ran using rthe above method in java, gives errors as follows,
    Mycode:
    String command = "/bin/sh /tmp/pub/alka/test.sh /tmp/pub/alka/abc/xyz/ul ul";
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec(command);
    int exitVal = proc.exitValue();
    System.out.println("Process exitValue: " + exitVal);
    java.io.IOException: CreateProcess: /bin/sh /tmp/pub/alka/test.sh /tmp/pub/alka/abc/xyz/ul ul error=3
         at java.lang.ProcessImpl.create(Native Method)
         at java.lang.ProcessImpl.<init>(Unknown Source)
         at java.lang.ProcessImpl.start(Unknown Source)
         at java.lang.ProcessBuilder.start(Unknown Source)
         at java.lang.Runtime.exec(Unknown Source)
         at java.lang.Runtime.exec(Unknown Source)
         at java.lang.Runtime.exec(Unknown Source)
         at DecryptTest.main(DecryptTest.java:18)
    Can anyone please help

  • Error while executing unix shell script from java program

    Hi All,
    I am trying to execute unix shell script from a java program using Runtime.execute() method by passing script name and additional arguments.
    Code snippet :
    Java Class :
    try{
         String fileName ="test.ksh";
         String argValue ="satish"; // value passed to the script
         String exeParam = "/usr/bin/ksh "+fileName+" "+argValue;
         Process proc = Runtime.getRuntime().exec(exeParam);
         int exitValue = proc.waitFor();
         sop("Exit Value  is : "+exitValue);
    catch(Exception e)
    e.printStackTrace();
    }Test.ksh
      export -- application realated paths..
      nohup  abc.exe 1> test.log 2>&1;
      $1
      exit.By running the above java class , i am getting exit Value: 139 and log file test.log of 0 bytes.
    when i am running the same command (/usr/bin/ksh test.ksh satish) manually, it's calling abc.exe file successfully
    and able generate the logs properly.
    Pls let us know where exactly i am stuck..
    Thanks in advance,
    Regards,
    Satish

    Hi Sabre,
    As per the guidelines provided by the article, i had done below changes..
    InputStream is = null;
    InputStreamReader iStreamReader = null;
    BufferedReader bReader = null;
    String line = null;
    try{
    String fileName ="test.ksh";
    String argValue ="satish"; // value passed to the script
    String exeParam = "/usr/bin/ksh "+fileName+" "+argValue;
    Process proc = Runtime.getRuntime().exec(exeParam);
    is = proc.getErrorStream();
    iStreamReader = new InputStreamReader(is);
    bReader = new BufferedReader(iStreamReader);
    System.out.println("<ERROR>");
    while((line = bReader.readLine()) != null)
    System.out.println("Error is : "+line);
    System.out.println("</ERROR>");
    int exitValue = proc.waitFor();
    sop("Exit Value is : "+exitValue);
    catch(Exception e)
    e.printStackTrace();
    Now , it's showing something like..
    <ERROR>
    </ERROR>

  • Sending arguments to shell script from Java program

    Hi,
    I am invoking a shell script within a Java program by runtime command.But I need to pass a variable to the shell script from the Java program!!!
    Please help me!!!
    Thanks!!!

    You can set environment variables as the second argument to Runtime.exec(). You can pass argument on the command line. So, what sort of argument do you want to pass?

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

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

  • Oracle 10g and Korn Shell Scripting

    I have a table,SALES_STAGING, with 3 main columns.
    Sales_Date, Sales_type,Sales_Code.
    A sale is added to the table then waits until approved to be processed. The Sales_Code is 1(waiting approval). Then manually changed to 2 every 30 minutes by sales staff except on weekends. By Monday,a large queue develops. This must be changed because the queue is slowing the system. Can someone help create a Unix Korn shell script to
    1) Run every 30 minutes via Crontab
    2)login to the Oracle DB.
    3)Count the number of records to be processed, if any.
    4)Update another 'log' table with the time it ran and the records to be processed
    5)if there are less than 20 add another 50 to be processed by changing the Sales_Code from 1 to 2.
    This would really help out tremendously! Thank you.

    Wait... Isn't this forum designed for the sharing of information? The experts here shouldn't be concerned whether the request is from a Student, Oracle newbie or Developer and should focus on the request. If you are capable of assisting then I am hoping you will out of the core respect for professionalism and the motivation to provide something of value to others. If not, don't waste my time or any one else by responding with preconceived judgments and insulting remarks as these will be reported.
    Sales transactions can peak at 20,000 per hour with an average of several million thru the week. Those sales by VIP customers are immediately identified and have a priority for approvals because their balances can easily exceed $1,000,000.00. There is a pre-approval process to be introduced but until programs can be modified/tested and deployed we need a quick fix. The programming system isn't slow, it's the limited human resources approving VIP customers. My request was to keep it simple and expand on it myself to include the entire scope of our project. dbms_scheduler, although a good idea will require DBA assistance and there is no resource available. I need a simple working model to give me some direction/ideas...

  • Looking for a One to Many script to extend the system partition for Windows 7 machines

    Looking for a One to Many script to extend the system partition for Windows 7 machines

    Pre-written scripts can be found in the repository:
    http://gallery.technet.microsoft.com/scriptcenter
    If you can't find what you need, you can request a script (no idea if anyone ever bothers to fulfill these requests though, I know I don't):
    http://gallery.technet.microsoft.com/scriptcenter/site/requests
    Let us know if you have any specific questions.
    Don't retire TechNet! -
    (Don't give up yet - 12,950+ strong and growing)

  • Looking for an email discussion lists script.

    HI! I am looking for a email discussion lists script that
    works on a windows
    platform. I have looked on Google but only found Mailman
    which is good but
    only works on UNIX/Linux. The other I found has to be
    installed via a
    setup.exe which is only good if you own and have direct
    access to your own
    server.
    Does anyone out there know of a email discussion lists script
    in ASP or PHP
    or similar that uses an ms-access or ms-SQL database and
    works on a windows
    platform?
    Paul

    trlyka wrote:
    I can't, for the life of me, find an email address for order support. Or any other support for that matter.
    I believe the only email support Apple offers is for Photo Services and iTunes Customer Service.

  • For loop in Korn Shell

    Hi,
    I want to write a C-Style for loop so that i can increment a variable using the loop.
    for ex : for (( i=0 ; i < 10 ; i++ )) ; do echo $i ; done
    The above mentioned code is not working for korn shell.
    How to write a c-style for loop in korn shell?
    Thanks
    Sandeep

    I guess thats possible only Bourne Shell.
    check this out.
    http://books.google.com/books?id=5Xw8ozq8CbIC&pg=PA193&lpg=PA193&dq=c-style+for+loop+in+ksh&source=web&ots=IeJgCNUzaZ&sig=e8zrdSultWKxnkR75ygHszdcHCA&hl=en&ei=e2CUSYLaFePetgejy5ibCw&sa=X&oi=book_result&resnum=8&ct=result#PPA154,M1
    http://www.unix.com/answers-frequently-asked-questions/12274-difference-between-ksh-bash-different-shells.html
    HTH
    Anantha.

  • Procedure call from SQL*Plus in Korn Shell Script

    I am trying to excute a procedure from sqlplus, truncate_audit_table. I doesn't execute. If I do it manually
    it executes. I have tried multiple ways, as below. This is inside a Korn Shell scripts that creates the procedure
    and counts the aud$ table. All that works, but does not truncate the aud$ table. It does not do it, no error, just
    passes it by. Does anybody know why?
    ${ORACLE_HOME}/bin/sqlplus -s / << EOF | tee -a ${LOG}
    set feedback on
    @/backup/oracle/orcl/audit/truncate_audit_table.sql
    select count(*) from sys.aud$;
    exec truncate_audit_table;
    exit
    EOF
    ${ORACLE_HOME}/bin/sqlplus -s / << EOF | tee -a ${LOG}
    set feedback on
    @/backup/oracle/orcl/audit/truncate_audit_table.sql
    select count(*) from sys.aud$;
    begin
         truncate_audit_table;
    end;     
    exit
    EOF
    This is the procedure that is being called:
    create or replace procedure truncate_audit_table
    as
    begin
    execute immediate 'truncate table sys.aud$';
    end;
    /

    aud$ is owned by sys. You can see it does the count with or without the "\".
    It creates the procedure under SYS , but does not execute it.
    Truncate aud$ table...
    Procedure created.
    COUNT(*)
    422
    1 row selected.
    ===============================================================
    audit_maintenance.ksh Completed: Thu Oct 26 14:03:17 GMT 2006
    ===============================================================

  • Korn shell script

    Hi,
    I have created korn shell script whoch takes records and spool into file as every column is ~ seperated. At the last I have to show total count as this one
    '[EOF <<count>>]' It is displaying but '[EOF' at one line and then ACTUAL COUNT value at next line.code is like this
    cnt variable in this I already take as count from query. Can anybody helps me?
    CREATEOUTPUT=`sqlplus -s $DATABASE@$ORACLE_SID <<SQLSCRIPT
         set heading off;
            set feedback off;
         set echo on;
         set verify off;
         set linesize 150;
         set pagesize 0;
         spool $filename
         /* 1.0 version developer needs to be change this with every relase*/
            SELECT '$BILL_SYSTEM'||' '||to_char(gnvgen.systemdate,'DD/MM/YYYY HH:MI:SS')||' '||'1.0' from dual;
         SELECT b.account_num ||'~'||
                        FROM pvaccount12 b,pvcustomer7 c,PROVIDER d,pvcustomertype2 e,pvbillsummary13 f
         WHERE b.customer_ref=c.customer_ref
         AND c.PROVIDER_ID= d.PROVIDER_ID  
         AND c.customer_type_id = e.CUSTOMER_TYPE_ID
         AND f.account_num =  b.account_num
         AND F.OUTSTANDING_DEBT_MNY <>0
         AND b.invoicing_co_id=3
         AND trunc(f.bill_dtm) <= trunc(gnvgen.systemdate)
         ORDER BY b.account_num;
         SELECT '[EOF'||'$cnt'||']' FROM dual;
         spool off;
         exit
         SQLSCRIPT
         `

    How did you set cnt variable ?

Maybe you are looking for

  • No Listner Connection Error

    I have a problem in connecting from client machine during log in I get the error of TNS:No Listner could any body help me solve this problem. null

  • HP Officejet J6450 and Snow Leopard...

    Upon completion of upgrade to Snow Leopard, lost communication with my HP printer via Bluetooth. Attempted to re-install HP software (after deleting it on my MAC). Hung up trying to select an available printer. Called online support for HP and was in

  • How to use mutex in uploading file

    Hi, All I used myfaces upload component. It works all right for me. Because I had a lot of process for the uploaded file and it might take long. So I'd like page to return (tell users that the file is in process) after successfully upload the file an

  • Report Title as a link or not.....

    Good morning, I am a new user to Business Object, not an IT professional.... I created a Crystal Report with specific parameters on it. I then forward ot our BO team for them to upload to the BO portal... I can click on the report title (blue font) a

  • Mail always being BCC to me

    Every time I send an Email to someone I immediately get a copy of the email sent to me. The BCC setting is turned off and I don't have anything typed in the CC when I send the mail. I have already tried deleting the account from the iphone and starti