Passing parameters into a shell script through alias Names ????

I have two alias names ord and dev. And the content of them are as follows.
alias ord
ord='cd ${ORDER}/bin; export APPL_NAME=order; . SetupAppl order'
alias dev
dev='cd ${APPL_ROOT}/bin; export APPL_ENV=dev; . SetupEnv dev'
Alias ord calls a shell script called SetupAppl. Alias dev calls a shell script called SetupEnv.
I am trying to pass a parameter when calling the alias name dev, something like dev WEST. And I
want to read that parameter inside the shell script SetupEnv.
The way I want to execute them, first run the alias ord and then the alias dev. But, when I try
to read the parameter in SetupEnv by $1 it is showing the value of the parameter passed to SetupAppl
ie order and not WEST.
Is there any way to read the value (WEST) passed as a parameter when executing the alias name.
example : dev WEST and reading the value WEST inside SetupEnv
The reason I am executing those scripts (SetupAppl and SetupEnv) with dot(.) in the front is because
those scripts have some export statements which needs to exported to the environment.
Any help on this is highly apprecaited

Hi everybody,
I posted same question earlier for UNIX/shell script and rec'd one response. Thanks to Bob.
But the requirement has been changed and now my mgr wants the same task using PL/SQL. Could somebody help me ?
Question again....
I am working on a task which gets report on every remote database.
I created a small database: ‘REPORTS_DB’ and I created 6 'sql' scripts on that database. While executing the first script, it calls the other 5 different 'sql' scripts. All these 5 sql scripts use a '@db_link' (hard coded) and gets that database's report to the database: REPORT_DB.
It is working well. But,
We have 42 databases and I have to get reports of all the 42 databases. Since it is not efficient to create 42 sets of sql scripts, I want to make it automated.
I know (but I don't know HOW) I can pass a parameter (database link name) while running the first script (which calls the other 5 scripts), so that the parameter replaces the @db_link in all the 5 scripts and gets the report of the related (@db_link) database.
Could somebody tell me how to do this task using SQL and PL/SQL ?
OR
send me a sample PL/SQL script to do this task?
Sorry for the inconvenience and thanks in advance.
- JT

Similar Messages

  • Executing shell script through PL/SQL

    Hi,
    I need some help regarding execution of shell script through Oracle PL/SQL.
    I have a shell script present in /abc/xyz folder with name search.sh , Through a PL/SQL procedure I am creating a file to store the report data.
    I want to execute /abc/xyz/search.sh from the PL/SQL procedure to delete all files created before 3 mins .
    1.     At first I took Java route and got following permissions granted for RECON user.
    GRANT USER SYS java.io.FilePermission <<ALL FILES>> execute ENABLED 351
    GRANT USER SYS java.lang.RuntimePermission readFileDescriptor * ENABLED 350
    GRANT USER SYS java.lang.RuntimePermission writeFileDescriptor * ENABLED 349
    2.     Then I created a simple java class for execution of OS command as below
    CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "OSCommand" AS
    import java.io.*;
    import java.util.*;
    public class OSCommand{
    public static String Run(String Command){
    try{
    Process proc = Runtime.getRuntime().exec(Command);
    int ext=proc.waitFor();
    return ("0");
    catch (Exception e){
    System.out.println("Error running command: " + Command +
    "\n" + e.getMessage());
    return(e.getMessage());
    3.     And a wrapper function as below to use this class
    create or replace
    FUNCTION OSCommand_Run(Command IN STRING)
    RETURN VARCHAR2 IS
    LANGUAGE JAVA
    NAME 'OSCommand.Run(java.lang.String) return int';
    4.     In my PL/SQL proceedure I am using following code to execute the command
    v_Return := OSCommand_Run('/abc/xyz/search.sh');
    to execute the shell script.
    Proceedure executes without any error and generates a new csv file with report data , however shell script does not get executed and hence all csv files created earlier remain as it is in the folder.
    Please help.

    Sven W. wrote:
    What happens if you remove the catch exception block from your java command?
    I asume you still might have a permission issue. But it could be hidden from you, because of the exception is catched and printed into nirvana.Executed the wrapper function OSCOMMAND_RUN as below
    DECLARE
    v_Return VARCHAR2(2000);
    BEGIN
    v_Return := OSCOMMAND_RUN('/recon/html/invoice/search.sh' );
    DBMS_OUTPUT.PUT_LINE('v_Return = ' || v_Return);
    END;
    And following is the result
    v_Return = 0
    Process exited.
    In case of exception it would had printed the exception.
    One more thing I noticed, even though I have taken following permissions
    GRANT     RECON     SYS     java.io.FilePermission     /abc/*     execute     ENABLED     347
    GRANT     RECON     SYS     java.io.FilePermission     /abc/xyz/*     execute     ENABLED     351
    GRANT     RECON     SYS     java.io.FilePermission     <<ALL FILES>>      execute     ENABLED     352
    GRANT     RECON     SYS     java.lang.RuntimePermission     readFileDescriptor     *     ENABLED     350
    GRANT     RECON     SYS     java.lang.RuntimePermission     writeFileDescriptor     *     ENABLED     349
    When I create a new search.sh in /abc dir I get following error
    v_Return = the Permission (java.io.FilePermission /abc/search.sh execute) has not been granted to RECON. The PL/SQL to grant this is dbms_java.grant_permission( 'RECON', 'SYS:java.io.FilePermission', '/abc/search.sh', 'execute' )
    Edited by: 960702 on Sep 25, 2012 10:34 AM

  • Running a shell script through java

    Hi all,
    I have a simple question here.
    How can I run a shell script through java and put the text output into a string.
    I'd be very grateful if you could show me sample code...
    Have a great day,
    Pesho

    Runtime.exec()
    There are plenty of examples. Read the following before continuing, however, as it will save alot of headaches:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • Running Shell scripts through JAva

    Hi,
    I tried to execute a Shell script through a Java program.
    The code I used is as below:
    import java.lang.*;
    import java.io.*;
    public class sys {
    public static void main(String[] args) {
    Runtime rt = Runtime.getRuntime();
    String[] callAndArgs = { "chgpasswd" };
    try {
    Process child = rt.exec(callAndArgs);
    child.waitFor();
    System.out.println("Process exit code is: " + child.exitValue());
    catch(IOException e) {
    System.err.println( "IOException starting process!");
    catch(InterruptedException e) {
    System.err.println( "Interrupted waiting for process!");
    The "chgpasswd" shell script calls the "passwd" command of Unix.
    It threw out an IO exception.
    Then I gave the parameter as "./chgpasswd". It now gave an exit value of 255.
    The "chgpasswd" script exists in the same directory as the .class file.
    I checkd up the exit code reference...it says exit value of 255 could mean as exit code out of range........an exit code > 255....which unfortunately has no documentation, I guess.
    Can you help ?

    This is on a Unix platform, correct? Assuming so...
    If I remember correctly, exit codes can be greater than 255. To get the real exit code equates to something like: exitcode & 512 to obtain the real exit code.
    Make sure "chgpasswd" shell script has the execute permissions set. Additionally, make sure that the first line of the script (the magic line) has the appropriate shell/interpreter to execute specified. For example, if "chgpasswd" were a Bourne (sh) script, the first like would be:
    #!/bin/shFor perl, it may be something like:
    #!/usr/bin/perlIt needs to be the absolute path to the shell/interpreter is the point.

  • Why I can't pass parameters into CR from VB6

    I want to Pass parameters into crystal report from VB6.
    But whatever I try, it don't work Fine,
    always Show the message "This field name is not known".
    Crystal Report::
    Parameter: a.@cmpy;
                       b.@p1
    formula:
    a. If {?@cmpy} ="USA" or {?@cmpy} ="usa" then
          "This is test 1 sentences"
       else if {?@cmpy}="TWD" or {?@cmpy} = "twd"  then
          "This is test 2 sentences"
    b. if trim({?@p1})="1" then "This is test 3 sentences"  
    VB::
    Public oApp As New CRAXDDRT.Application
    Public oRpt As CRAXDDRT.Report
    oRpt.ParameterFields(1).ClearCurrentValueAndRange
    oRpt.ParameterFields(2).ClearCurrentValueAndRange
    oRpt.ParameterFields(1).AddCurrentValue ("TWD")
    oRpt.ParameterFields(2).AddCurrentValue ("1")  
    I had trid to use "IsCurrentValueSet" function to check whether parameter was set or not, and It responsed "Ture",so I so confused about it.
    Anyone know about this??
    ps. I had trid other way that change the formula indirectly, although it can work fine, but it isn't a right way to solve my problem.
    Edited by: DeanLai on Jun 22, 2010 8:54 AM

    I Find something.
    First I tried to add parameter and wanted to see these value on Report.
    So I inserted {?@cmpy} and {?@p1} into report, and used VB code
    "oRpt.ParameterFields(1).AddCurrentValue ("TWD")" and "oRpt.ParameterFields(2).AddCurrentValue ("1")",
    then ran the process, but it didn't display any value on report,
    so why it couldn't pass value into parameter??
    then I tried other way which was to add new parameter, and used the same way to pass
    value into parameter, then it can display value on report.
    So the different between these is {?@cmpy} and {?@p1} which come from
    Stores Procedure.
    While I set Database in crystal report, set all value into Store Procedure's
    parameter(the window about "Enter Parameter Values"), then it automatic come out the DB columns and parameter(SP parameter)
    , course include {?@cmpy} and {?@p1}.
    Do this problem cause my question?
    Can we pass value into parameter which come from SP parameter??
    Can we use these parameter into forumla??
    Edited by: DeanLai on Jun 30, 2010 11:56 AM

  • Passing parameters into an URL Services portlet

    Hi,
    is there any way to pass parameters into an URL Services portlet ? I want to give the user the ability to set a preference for which sections of an XML file should be displayed. The preference should be passed into the XMLFilter which should add these parameters as XSLT variables to the stylesheet. Is this possible ?
    Cheers,
    Ernst

    As of now we do not have provision to pass parameters to the portlet dynamically. However, if required, at most could be used is headerTrim tag and footerTrim tag. If you want to discard some data from mid of the file, its not supported.
    bye
    Baig
    null

  • Pass parameters into CellRenderer

    Hello!
    I want to pass parameters into CellRenderer.
    How can I do that?

    Found solution!
    Create method, that set my Bean in CellRenderer, in what I keep my values, and call this method when create my CellRenderer. Than Use MyBean inside CellRenderer when it render cell.
    JSP:
    <hbj:tableView id="NewTable" model="LotsBean.ModelLots"
              design="TRANSPARENT"
              headerVisible="false"
              footerVisible="false"
              fillUpEmptyRows="false"
              selectionMode="NONE"
              visibleFirstRow="1"
              rowCount="16"
              width="100%" >
              <%  MyCellRenderer MyCell = new MyCellRenderer();
                     MyCell.setST(MyBean);
                     NewTable.setUserTypeCellRenderer(MyCell); %>
         </hbj:tableView>
    CellRenderer class:
         public void setST(user_registration_bean Bean){
              MyBean = Bean;

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

  • SQL-Scripts into a Shell script

    Hi!
    After creating the database on a Linux machine, we need to create our Schema in that database.This Schema has many objects(tables, views,
    procs, triggers etc.). So executing each individual script would not be sensible. Is it possible to pack all sql scripts into one shell script and run that one?
    Thanks for your feedback/examples/links!

    If it's one-off task, why not put all of them in a SQL file and run it from SQL* Plus rather than using shell to cause sql plus which will in turn have to call the script?
    If it's a recurring task and you insist that you want to do it from Unix shell, you can do something like this:
    Place all scripts in a single file and put it under $HOME for ex. (save it as run_all_scripts.sql)
    Then write a shell script something like this:
    #!/bin/ksh
    connect_schema=scott/tiger
    sqlplus -s $connect_schema <<EOF
    @$HOME/run_all_scripts.sql
    EOF
    Regards
    Venkat

  • How we can call or execute a SHELL script through Oracle forms or Reports

    How we can call or execute a SHELL script through Oracle forms or Reports.Its urgent.......

    Use HOST command.

  • 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

  • Passing parameters in a shell shel script

    Hi everybody,
    I am working on a task which gets report on every remote database.
    I created a small database: ‘REPORTS_DB’ and I created 6 'sql' scripts on that database. While executing the first script, it calls the other 5 different 'sql' scripts. All these 5 sql scripts use a '@db_link' (hard coded) and gets that database's report to the database: REPORT_DB.
    It is working good. But,
    We have 42 databases and I have to get reports of all the 42 databases. Since it is not efficient to create 42 sets of sql scripts, I want to make it automated.
    I know (but I don't know HOW) I can pass a parameter (database link name) while running the first script (which calls the other 5 scripts), so that the parameter replaces the @db_link in all the 5 scripts and gets the report of the related (@db_link) database.
    Could somebody send me a sample shell script to do this task?
    OR, is there any way to do this task without using shell script ?
    (BTW, we are using korn shell on sun Solaris)
    Thanks in advance.
    - JT

    Hi everybody,
    I posted same question earlier for UNIX/shell script and rec'd one response. Thanks to Bob.
    But the requirement has been changed and now my mgr wants the same task using PL/SQL. Could somebody help me ?
    Question again....
    I am working on a task which gets report on every remote database.
    I created a small database: ‘REPORTS_DB’ and I created 6 'sql' scripts on that database. While executing the first script, it calls the other 5 different 'sql' scripts. All these 5 sql scripts use a '@db_link' (hard coded) and gets that database's report to the database: REPORT_DB.
    It is working well. But,
    We have 42 databases and I have to get reports of all the 42 databases. Since it is not efficient to create 42 sets of sql scripts, I want to make it automated.
    I know (but I don't know HOW) I can pass a parameter (database link name) while running the first script (which calls the other 5 scripts), so that the parameter replaces the @db_link in all the 5 scripts and gets the report of the related (@db_link) database.
    Could somebody tell me how to do this task using SQL and PL/SQL ?
    OR
    send me a sample PL/SQL script to do this task?
    Sorry for the inconvenience and thanks in advance.
    - JT

  • How do i print parameters in shell script through java

    Hi,
    I am sorry if have posted this query in wrong thread!!!
    How do i print the parameter in shell script which are passed from java programm?
    i have tried in different ways.. but the actual param value is not printing when i execute the java programm
    java code is here
    import java.io.IOException;
    public class TestShell {
          * @param args
    public static void main(String[] args) {
             String inputFilePath=args[0];
              String inputFileName=args[1];
              String outputFileName=args[2];
              String outputFilePath=args[3];
              Runtime r = Runtime.getRuntime();
              String[] cmdArray = new String[]{"Test.sh",inputFilePath, inputFileName, outputFileName, outputFilePath};
              try {
                   r.exec(cmdArray);
                   System.out.println("Test.sh executed successfully.");
              } catch (IOException e) {
                   e.printStackTrace();
    }I need a shell script to print paramenters (inputFilePath, inputFileName, outputFileName, outputFilePath)
    Thanks,
    Jasmin

    user13836688 wrote:
    But my code is something look like thisWell unless I've completely lost my marbles (possible) or Java Runtime.exec() does something I've never heard of, I can't even see how that will execute. For a start, assignments in the Bourne shell take the form ofinfile = $inputFilename;orinfile = "inputFilename";not what you've got; and the first form would only work if you've set the appropriate environment variables.
    Are you sure you're not confusing this with a Javascript script?
    Winston
    Edited by: YoungWinston on Apr 18, 2011 12:51 PM
    And BTW, you don't need to put ';' at the end of each statement, unless there's more than one on a line.
    Edited by: YoungWinston on Apr 18, 2011 12:54 PM
    BTW2: 'printf "%d", inpath' also looks very dodgy, since 'inpath' is unlikely to be a number (in fact, it's unlikely to be anything).
    I think you might want to get a book on scripting.

  • Passing mulitple parameters to unix shell script via File adapter

    Hi,
    I have the following usecase.
    I have a set of files A, B, C, D  etc in a directory dir.  I also have a EOT ( end of transaction file).
    I need to merge this file once the EOT file is present in XI application server (  using NFS with File adpter).
    I have a script which can take the following paramters:
    1. EOT file name
    2. File names for A,B,C,D
    3. Directory names.
    Is it possible to send muliple parameters to the unix script from the File adapter?
    please share any blogs which do so.
    Thanks in advance,
    Best Regards
    Abhishek

    Hi,
    You can always call script from file adapter using "OS command" functionality, pass additional parameter like you do in unix for existing script (exact command which you type on unix prompt).
    Adapter will simply pass your OS command to operating system, so from XI point of view nothing is changed and it is your script which should take care of parameters.
    Regards,
    Gourav

  • Passing long string to shell script from java

    I am trying to passa a long string to a shell process through java,
    call is like
    Runtime rtime = Runtime.getRuntime();
    String callAndArgs[] = {"/apps/jetty4/jstest/jstest.sh",jarCo,queue,text};
    Process child = rtime.exec(callAndArgs);
    here the string text is :
    |HEADER|JAR933|[email protected]|290001|OL0006528|WIN4015444|SHAFT_FORGING|1.0|Baan EDM|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
    |290001|WIN4015444|00||||2|SHAFT FORGING|9|AXELSMIDE|3|ACHSE SCHMIEDEST�CK|4|ARBRE FORG�|f|AKSELITAOS|||||||||||||||||||||||No||Approved|41.0|Mechanic|Yes|pc||WIN4015444|EL20|Purchased|Metric||0|20051120|||||Released||||||||||||||||No||||||||||||||||||||||||||||||||
    Now i use this string in shell script to pass as an argument to other class. But the string gets truncated.
    How do i solve this?

    It appears that your os is truncating the data - Java's not involved.
    Maybe write the data to a file and then read it into the external program some way.

Maybe you are looking for

  • Wireless printing for an HP Laserjet 3330 - need print server

    Anyone know of a good wireless print server that will work with an HP Laserjet 3330?  I don't care as much about the full multi function capability as I do simply printer remotely.  Just returned a Linksys that wasn't compatible and don't want to go

  • External hard drive reformatting error: 'could not unmount disk'

    I've bought a TrekStor DataStation maxi light 2TB external harddrive and I am trying to reformat it so I can use it with my Mac. Unfortunately when I try to either 'Erase' or create a partition as detailed here: https://discussions.apple.com/thread/2

  • How do i install lightroom on multiple macs

    I have a macbook pro and a iMac desktop and i am trying to install lightroom on my iMac after it has already been installed on my macbook....so how do i do this

  • Minisap 4.6 d problem please help

    have installed the minisap 4.6d system in the windows 200 prof os. i had the following problem in my minisap access. while Displaying table contents with transactions SE11 or SE16 gives an error "No changes on SAP objects allowed". while Accessing th

  • Can't display power icon on toolbar

    The power icon on my Toshiba laptop disappeared.  I right clicked the notification area, clicked customize, and it won't let me turn on the option to display the icon.  I read somewhere to go to the control panel and go to a certain section but that