Example of Unix Korn Shell to run .scr (similar to NT .bat)??

Wondering if anyone has an example of a Korn shell script that they use in Unixto run the Essbase script (.scr) to load up an outline.I am using NT .bat and will do the same in Unix. I will be so gratefull.Please email me [email protected]! Karim

Hi,
I have an application (very small) that connects to
our database. It needs to run in our UNIX environment
so I've been working on a shell script to set the
class path and call the JAR file.
#!/bin/sh
exec /your/path/to/java -cp your:class:paths:here -MoreJvmOptionsHere your.package.and.YourClass "$@"Store this is a file of any name, e.g. yuckiduck, and then change the persmissions to executechmod a+x yuckiduckThe exec makes sure the shell used to run the script does not hang around until that java program finishes. While this is only a minor thing, it is nevertheless infinite waste, because it does use some resources but the return on that investment is 0.
CFG_DIR="`dirname $0`"You would like to fetch the directory of the installation out of $0. This breaks as soon as someone makes a (soft) link in some other directory to this script and calls it by its soft linked name. Your best bet if you don't know a lot of script programming is to hardcode CFG_DIR.
OLDDIR="`pwd`"
cd $PLCS_ROOT_DIRVery bad technique in UNIX. UNIX supports the notion of a "current directory". If your user calls this program in a certain directory, you should assume that (s)he does this on purpose. Making your application dependent on a start in a certain directory ignores the very helpful concept of 'current directory' and is therefore a bug.
cd $OLDDIRThis has no effect at all because it only affects the next two lines of code and nothing else. These two lines, however, don't depend on the current directory. In particular this (as the cd above) does not change the current directory for the interactive shell your user is working in.
echo $EXIT_STATUS
exit $EXIT_STATUSEchoing the exit status is an interesting idea, but if you don't do this for a very specific purpose, I recommend not to do this for the simple reason that no other UNIX program does it.
Harald.

Similar Messages

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

  • Windows connect to unix kick off korn shell - can it be done?

    We are running CF7 on windows, but I need to be able to read
    and kick off a korn shell job that is sitting on a unix box. I've
    looked at both cfdirectory and cffile, but I'm at a loss if I can
    do this. Does anyone know the steps I need to do this? Is it
    possible? Any help would be great.
    thanks,
    bj

    ugly vs elegant
    I'm a newbie so you'll get the ugly.
    1) Have unix poll a directory
    2) Have CF drop a file in that directory
    3) Have unix run korn shell if file exists
    Good luck!

  • Can I just issue sqlplus command like a Korn shell does in python?

    Hi
    I have a question on python as an Oracle DBA. Do I have to have cx_oracle or another similar compenent in order to access Orade database? Can I just do sqlplus like a Korn shell does?
    I am an Oracle DBA. Daily job requires shell scripting. I am skilful at Korn/BASH which I use on a daily basis to interact with database. However, I found them not powerful and flexible enough to handle text and strings. I am new to both Perl and Python. I pick Python because it is easy to read and maintain. Learning curve is not as steep as Perl.
    I am not a developer who cares much about data types compatability or APIs. I do care about how to pass Unix variables in Python. A typical task is like
    =================================================
    set Unix environment variables (each database has a line in a file)
    use sqlplus to connect to each database specified in the file, i.e. looping
    get information I want and store them in files, i.e. logs
    end loop
    do text/string manipulation againt the log file
    if error is found, send email alert to DBA
    =================================================
    Thanks,
    Kevin

    Kevin,
    Python has some great libraries to do what you are asking in the Unix enviornment:
    To get enviornmental variables:
    ====================
    import os
    # store the env var audit_username in a variable; if it doesn't exist, use 'davew' as the default
    username = os.getenv("audit_username",default='davew')
    To run Unix commands:
    ====================
    import commands
    # run a command from unix (example from Python manual
    commands.getstatusoutput('ls /bin/ls')
    Dave Warner

  • SAP and Korn shell scripts

    Hi,
    It looks SAP default is c-shell only.  I have an issue, when remote calls (rsh) to OS to run a command, k-shell script does not source the .profile.  Do any one face this issue? how it was resolved.
    Thanks, R

    Hi,
    It is a very, very long time, but as far as I remember that is an issue with the rsh.
    I think the solution is not to use the Ksh on the destination.
    I think there is/was a note indicating so.
    For that reason SAP does recommend to use only the cshell.
    Edited by: Fidel Vales on Nov 14, 2009 11:02 AM
    hi again.
    Check note 202227.
    > In general, you can use the Korn shell (ksh) as a login shell, however, note that the implementation of the Korn shell differs among the different UNIX platforms. This has lead to problems within SAP, in particular this is the case when you start external programs from an SAP system.
    and note 188772
    > The .profile file is not read under ksh.

  • 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

  • How can i pass the Input value to the sql file in the korn shell ??

    Hi,
    How can i pass the Input value to the sql file in the korn shell ??
    I have to pass the 4 different values to the sql file and each time i pass the value it has to generate the txt file for that value like wise it has to generate the 4 files at each run.
    can any one help me out.
    Raja

    Can you please more elaberate., perhaps you should more elaberate.
    sqlplus is a program. you start it from the korn shell. when it's finished, processing control returns to the korn shell. the korn shell and sqlplus do not communicate back and forth.
    so "spool the output from .sql file to some txt file from k shell, while passing the input parameters to the sql file from korn shell" makes no sense.

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

  • Command Line Recall (Korn Shell) - Last Command Not Blank

    I'm using emacs for command line recall, so I use the up and down arrow keys, which work fine.
    However, I come from a Tru64 background, and when I go back through the commands, and then come forward again, I expect to be able to go past the last command entered and return to a blank command line, so if I don't want to choose anything from history I can enter a new command. What's happening for me on the Solaris box I am now working on is that going forward in history sticks on the last command entered, so I have to backspace it to enter anything new.
    Any ideas on how I can change this behaviour?

    Kevin,
    Python has some great libraries to do what you are asking in the Unix enviornment:
    To get enviornmental variables:
    ====================
    import os
    # store the env var audit_username in a variable; if it doesn't exist, use 'davew' as the default
    username = os.getenv("audit_username",default='davew')
    To run Unix commands:
    ====================
    import commands
    # run a command from unix (example from Python manual
    commands.getstatusoutput('ls /bin/ls')
    Dave Warner

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

  • Korn Shell requiered

    In the requisites to install Oracle 10g, it requires the pdksh-5.2.14-780.1
    I got Suse Enterprise 10 with SP1, and I got this korn shell, ksh-93r-12.33, not the pdksh
    Will be a problem that I don't use the pdksh??
    Can I use the one I got install??
    Thanks in advance.

    I downloaded this articles from the Oracle page:
    http://download.oracle.com/docs/cd/B19306_01/install.102/b15660/pre_install.htm#BABCHAED
    There it says the following:
    Prerequisite packages for SUSE Linux Enterprise Server 9:
    binutils-2.15.90.0.1.1-32.5
    gcc-3.3.3-43.24
    gcc-c++-3.3.3-43.24
    glibc-2.3.3-98.28
    gnome-libs-1.4.1.7-671.1
    libstdc++-3.3.3-43.24
    libstdc++-devel-3.3.3-43.24
    make-3.80-184.1
    pdksh-5.2.14-780.1
    sysstat-5.0.1-35.1
    xscreensaver-4.16-2.6

  • Run powershell commands on a bat file

    Hello,
    I can call powershell on command line as below:
    C:\>echo I am in Command Shell
    I am in Command Shell
    C:\>powershell
    Windows PowerShell
    Copyright (C) 2009 Microsoft Corporation. All rights reserved.
    PS C:\> Write-Host I am in Powershell
    I am in Powershell
    PS C:\> exit
    C:\>echo I returned to Command Shell
    I returned to Command Shell
    But I want to create a bat file and run these commands in bat file. To do this, I copied and pasted same codes to Test.bat file:
    echo I am in Command Shell
    powershell
    Write-Host I am in Powershell
    exit
    echo I returned to Command Shell
    But after "powershell" command nothing worked as below:
    C:\>.\Test.bat
    C:\>echo I am in Command Shell
    I am in Command Shell
    C:\>powershell
    Windows PowerShell
    Copyright (C) 2009 Microsoft Corporation. All rights reserved.
    PS C:\>
    I want this output:
    I am in Command Shell
    I am in Powershell
    I returned to Command Shell
    How can I handle this problem.
    PS: I don't want to use powershell file (*.ps1).
    Thanks

    In my Test.bat file there are some commands. My Test.bat file is sth like this:
    @echo off
    echo I am in Command Shell
    powershell.exe
    Write-Host I am in Powershell
    $Var = "Some words"
    Write-Host My ID: $Id, String: $Var
    exit
    echo I returned to Command Shell
    There are other different commands, such as importing modules or setting variables or configuring computer settings,.... So, I think "powershell -command" is not applicable. 
    In brief;
    Above codes work in command line.
    But when I use same codes in a batch file, nothing works in powershell. Result is sth line this:
    C:\>Test.bat
    I am in Command Shell
    Windows PowerShell
    Copyright (C) 2009 Microsoft Corporation. All rights reserved.
    PS C:\>

  • Unix shell script run from pl/sql procedure

    Hi Guru
    I want to run unix shell script from pl/sql procedure. Actual I want to run it from developer 10g form.
    Please guide me in this regards
    Regards
    Jewel

    Look at the host or client_host builtins in the help

  • Unix master shell script to run jobs in parallel with dependency

    I need a master shell script which would call the following shell scripts as per below order. Kindly note that if any shell script fails then the master shell script should abort.
    Level 1     PRODUCTS
         SP_ROST_DLY_STG_lD
         SP_ROST_DLY_ITG_lD
    After Level 1 completes run below two shell scripts in parallel:
    Level 2     SP_IDL_EDGE_CON_POSTN_STG_Ld ,     SP_IDL_EDGE_ACCT_POSTN_STG_LD
    After Level 2 completes run below shell scripts as per the seqeunce and in parallel:
    Level 3     SP_IDL_EDGE_ACCT_STG_LD ,     SP_IDL_EDGE_CONT_STG_LD
         SP_IDL_EDGE_ACCT_STG_VAL ,     SP_IDL_EDGE_CONT_STG_VAL
         SP_IDL_EDGE_ACCT_ITG_Ld ,     SP_IDL_EDGE_CON_ITG_Ld
    After Level 3 completes run below shell scripts as per the seqeunce and in parallel:
    Level 4     SP_IDL_EDGE_CONT_POSTN_ITG_LD ,     SP_IDL_EDGE_VISITS_LD
         SP_IDL_EDGE_ACCT_POSTN_ITG_LD ,     SP_IDL_EDGE_VISITS_DTL_LD

    can i avoid using set -e and use some other method so that if there is an error in previous job then the next job is not triggered.Sure, but it is ugly.
    The below is not the only way to do this...
    Wrap every place you start another script with:
    $ if ! MYSCRIPT; then
        echo Script MYSCRIPT failed. >&2
        exit 1
    fibut the wrapper for parallel scripts is even worse:
    $ MYSCRIPT &
    $ MYSCRIPT_JOBNO=$!
    $ MYSCRIPT2 &
    $ MYSCRIPT2_JOBNO=$!
    $ MYSCRIPT_STATUS=`wait ${MYSCRIPT_JOBNO}`
    $ if [ ${MYSCRIPT_STATUS} -ne 0 ]; then
        echo Script MYSCRIPT failed. >&2
        exit 1
    fi
    $ MYSCRIPT2_STATUS=`wait ${MYSCRIPT2_JOBNO}`
    $ if [ ${MYSCRIPT2_STATUS} -ne 0 ]; then
        echo Script MYSCRIPT2 failed. >&2
        exit 1
    fi
    ...Now, doesn't a simple 'set -e' look much better?

Maybe you are looking for