5 Replies Latest reply on Mar 10, 2014 9:32 AM by 994543

    Passing parameter / variable to linux script




      I am trying to make Oracle work with schell script in Linux and i require two parameters to run it ( linux script that is).


      Is there a way to pass parameters to linux using a job or program ?


      I need to run my script as /scripts/sh script.sh parameter1 parameter2


      Thank you!

        • 1. Re: Passing parameter / variable to linux script
          Partha Sarathy S

          You are using this script to execute a job in oracle? If so, you can check this.


          creating a job with arguments


          Message was edited by: Partha Sarathy S

          1 person found this helpful
          • 2. Re: Passing parameter / variable to linux script

            vi script.sh



            echo "variable 1 is : $parameter1"
            echo "variable 2 is : $parameter1"


            ---- Use those variables in your remaining code


            Execute the code by passing the value for the parameters:


            sh script.sh parameter1 parameter2


            • 4. Re: Passing parameter / variable to linux script


              import java.io.*;

              import java.util.ArrayList;


                  public class Util extends Object {


                   public static String RunThis(String args){

                       Runtime rt = Runtime.getRuntime();

                       String result = "";

                       ArrayList<String> res = new ArrayList<String>();


                       try {

                       String[] cmd = {





                          Process p = rt.exec(cmd);    

                          BufferedReader br_in = null;

                          br_in = new BufferedReader(new InputStreamReader(p.getInputStream()));

                          String buff = null;


                          while ((buff = br_in.readLine())!= null) res.add(buff);


                          for (int i = 0; i< res.size() ; i++) {

                              if (i > 0) result += "\n";

                              result += res.get(i);



                          int rc = p.waitFor();


                       catch (Exception e) {


                          result += e.getMessage();


                       finally {

                          return result ;







              create or replace function RUN_OS_COMMAND( p_cmd  in varchar2) return varchar2


              language java

              name 'Util.RunThis(java.lang.String) return java.lang.String';



              and give execute right to user


              call dbms_java.grant_permission('USERNAME','SYS:java.io.FilePermission', '/usr/bin/zip', 'execute');commit;



              call the procedure with your arguments.


              execute dbms_output.put_line( RUN_OS_COMMAND('/usr/bin/zip param1 param2 param3...') );

              • 5. Re: Passing parameter / variable to linux script

                Spot on mate!


                The only thing that i forgot to uncomment in my script



                stupid mistake ... thank you again!