Running Unix script from stored procedure

At present, I run a unix script to export my data for backup using telnet. I would like my users to run the commands on their own without my help. My users do not know telnet (they have no IT knowledge). So, I plan to create a form using Developer/2000 and let them run the procedure thru a stored procedure.But, my problem is how can a stored procedure call a unix script?

Hi,
solution, used by me.
Create a stored procedure that produces a text file with utl_file. The content of the file is the script you want to execute on your Unix box.
On your Unix Box write a shell script that scans the utl_file_dir for Files. If a file is in, chmod 744 to grnt execute rights to it and execute it.
I have a example if you want.
Start the script with crontab or let it loop with a sleep inside.
HTH
Detlev

Similar Messages

  • How can i run unix script from my apex page

    how can i run unix script from my apex page and take the output of unix script as a hidden variable and display it on the report region of that page

    I had a requirement to run a Fortran program against some data that woudl be extracted from the database after the user set up their filtering criteria and made some additional input. SInce the program was to complex to conver to PL/SQL, we decided to try and invoke it from Apex. This is how I did it.
    1. I followed the steps in Tim Archer's excellent article "Oracle External Procedure to Run Host Commands" (http://www.timarcher.com/?q=node/9). If the link does nto work, google the article's title.
    Using this steps I created a function which accepts any OS command, including calling my own shell scripts, and runs them. I called my PL/SQL function "shell" instead of "USF_RUN_HOST_CMD " as Tim did in his example (step 9).
    2. In Apex,
    a. I created a button to run my shell command. (I named it P2_RUN_SHELL)
    b. I created a PL/SQL process whose source looks as follows:
    shell('/home/ackness/scripts/cr_xcf_file.sh > /tmp/cr_scfp_file.log');
    and which was conditioned on the the button P2_RUN_SHELL.
    It works like a charm.
    Note: since you can run your own scripts using this method, you can encapsulate a series of commands in a UNIX shell script and invoke that script from Apex. This allows you to be able to test or run you commands from the command line as well as Apex and makes it easier to develop/debug/enhance the scripts in the future.
    Ackness

  • Running a sql script from stored procedure

    Hi everyone!
    Has anybody tell me how to execute a sql script from a stored
    procedure!
    Thanks in advance!
    Sasa

    >
    Hi everyone!
    Has anybody tell me how to execute a .sql file from a stored
    procedure!
    Thanks in advance!
    Sasa Sorry, a .sql file!!

  • File Ownership while executing sql script from stored procedure

    We have a test_command.sql script which is spooling the result into a file. From database we have one Store Procedure(run_sql) which is
    calling and executing the .sql script.
    When we are calling the sql script directly from the database, i e SQL > @/dccops/test_command.sql it is creating the
    file under the Ownership of OS user which is connected to the system.
    The problem we are facing is when we are executing the stored procedure i e exec run_sql(), the file is creating under
    Oracle User.
    Could u please suggest me a solution inorder to create the output file under the user who is logged to the OS.

    First of all, your usage of IM speak is NOT appreciated. Please do not address anyone as if they were a 12-year old.
    'Our Applcation is in C. So we have to call the procedure to run the sql script.'
    This is just utter nonsense!
    Oracle has Pro*C which allows Embedded SQL in C. There is also OCI (Oracle Call Interface) to call Oracle directly in C, and there is OCCI, to do the same in C++.
    Apart from that, Oracle has Ole DB for Windows platforms, to allow for a .NET compatible interface to Oracle.
    There is NO NEED AT ALL to call PL/SQL to run a SQL script.
    Sybrand Bakker
    Senior Oracle DBA

  • Calling shell script from stored procedure.

    Hi Everybody,
    Could anyone tell me how to call a shell script from a stored procedure.
    Thanks,
    Vasu

    You would need to write a Java stored procedure that calls out to the underlying operating system. Tom Kyte has an example of this here
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:952229840241
    Make sure that you're very aware of the security implications here, however. Your commands will run as the Oracle user on the host operating system, which makes it possible that a coding error and/or an attacker could do something like delete or corrupt Oracle data files, so you'll probably want to harden the code substantially.
    Justin

  • Calling a perl script from stored procedure

    Can anyone tell me how to call/run a perl script from a stored procedure? If you have a sample code, please include it.
    Thanks in advance

    If you have a web server setup that runs perl, you can do this by using the utl_http package...Here is some code I use to run a perl script and print the results to a web page on our site.
    The in_URL parameter is the address of the perl code(i.e. http://website/path/perlscript?param1=value1&param2=value2 etc)
    PROCEDURE call_perl(in_URL VARCHAR2) IS
    /* This is setup to allow a perl program to be submitted as a batch program
    using the standard Portal batch program.
    Sometimes these jobs take a long time to run, so the timeout value must
    be set to a large value. The default timeout is 60 seconds, which is not long enough. */
    req utl_http.req;
    resp utl_http.resp;
    value VARCHAR2(1024);
    BEGIN
    req := utl_http.begin_request(replace(utl_url.escape(replace(in_URL,'%3A',':')),CHR(13)));
    utl_http.set_transfer_timeout(req, 18000); -- Set timeout to 5 hours for this specific request.
    resp := utl_http.get_response(req);
    LOOP
    utl_http.read_line(resp, value, TRUE);
    htp.p(value);
    END LOOP;
    utl_http.end_response(resp);
    EXCEPTION WHEN utl_http.end_of_body THEN
    utl_http.end_response(resp);
    WHEN utl_http.init_failed THEN
    htp.p('INIT FAILED');
    WHEN utl_http.request_failed THEN
    htp.p('REQUEST FAILED');
    htp.p(NVL(utl_http.get_detailed_sqlerrm,' No more detail available.'));
    END;
    If you don't have a web server setup, I don't know offhand how you could do this.
    Laurel

  • Problem while running the report from stored procedure

    Hi,
    I using stored procedure to generate my report.
    my stored procedure's code looks like this.
    CREATE OR REPLACE PROCEDURE PROJECTOVERVIEWREPORT1(query in VARCHAR2)
    IS
    myPlist SRW_PARAMLIST;
    myIdent SRW.Job_Ident;
    myStatus SRW.Status_Record;
    BEGIN
    srw.start_Debugging;
    myPlist := SRW_PARAMLIST(SRW_PARAMETER('',''));
    srw.add_parameter(myPlist,'GATEWAY','http://localhost:8888/reports/rwservlet');
    srw.add_parameter(myPlist,'SERVER','rep_kalyan1');
    srw.add_parameter(myPlist,'REPORT','BillFormat.RDF');
    srw.add_parameter(myPlist,'USERID','atl3_dev_jul04/atl3_dev_jul04@mgi');
    srw.add_parameter(myPlist,'destype','file');
    srw.add_parameter(myPlist,'desformat','pdf');
    srw.add_parameter(myPlist,'documentnumber','17181');
    srw.add_parameter(myPlist,'papertype','N');
    srw.add_parameter(myPlist,'desname','c:\temp\17181.pdf');
    myIdent := srw.run_report(myPlist);
    myStatus := srw.report_status(myIdent);
    srw.stop_Debugging;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    NULL;
    END PROJECTOVERVIEWREPORT1;
    Iam running the oc4j instance and the report server in my local machine.
    when i have typed http://localhost:8888/reports/rwservlet
    Iam able to see the help page.
    My rdf file is placed in OralceHome/reports/integ folder.
    Iam executing my stored procedure it is returning some error.
    Iam doing any thing wrong.
    Do i need to modify anything.
    Is the place of rdf file correct.
    plz help me solving the above problem.
    --Kalyan                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    This is the error message iam getting..
    any idea????
    * WELCOME TO EVENT-BASED-REPORTING API *
    * API-Version : 9i *
    * (C) Oracle Corporation, 2000 *
    * Debugging turned ON *************************************
    *** Length of Paramlist : 1
    OK : Parameter added : GATEWAY=http://localhost:8888/reports/rwservlet
    *** Length of Paramlist : 2
    OK : Parameter added : SERVER=rep_kalyan1
    *** Length of Paramlist : 3
    OK : Parameter added : REPORT=BillFormat.RDF
    *** Length of Paramlist : 4
    OK : Parameter added : USERID=atl3_dev_jul04/atl3_dev_jul04@mgi
    *** Length of Paramlist : 5
    OK : Parameter added : DESTYPE=file
    *** Length of Paramlist : 6
    OK : Parameter added : DESFORMAT=pdf
    *** Length of Paramlist : 7
    OK : Parameter added : DOCUMENTNUMBER=17181
    *** Length of Paramlist : 8
    OK : Parameter added : PAPERTYPE=N
    *** Length of Paramlist : 9
    OK : Parameter added : DESNAME=c:\temp\17181.pdf
    Starting run_report: building url
    *** Building URL (RUN_REPORT)
    OK : URL built : http://localhost:8888/reports/rwservlet?SERVER=rep%5Fkalyan1&REPORT=BillFormat%2ERDF&USERID=atl3%5Fdev%5Fjul04%2Fatl3%5Fdev%5Fjul04%40mgi&DESTYPE=file&DESFORMAT=pdf&DOCUMENTNUMBER=17181&PAPERTYPE=N&DESNAME=c%3A%5Ctemp%5C17181%2Epdf&statu
    *** Submitting HTTP Request
    *** using URL :http://localhost:8888/reports/rwservlet?SERVER=rep%5Fkalyan1&REPORT=BillFormat%2ERDF&USERID=atl3%5Fdev%5Fjul04%2Fatl3%5Fdev%5Fjul04%40mgi&DESTYPE=file&DESFORMAT=pdf&DOCUMENTNUMBER=17181&PAPERTYPE=N&DESNAME=c%3A%5Ctemp%5C17181%2Epdf&statusf
    ERROR : HTTP request failed

  • Run Unix script from abap

    Hi
    Friends  i am runing a abap report which genrate a ( eft.txt ) text file in /usr/tmp/
    Now  i want  to run a unix script   which encript this file.
    I  have created this command in SM69
    type = customer
    command name = ZENC
    Operation system = unix
    externl program     = sh
    parameter for external program = /usr/tmp/ enc.sh eft.txt eftdc eftdo
    enc is unix script and eft.txt is imput text file eftdo eftdc are encripted  files.
    I am us the function module SXPG_CALL_SYSTEM'
    it is ending with  following messege
    1      5     hello
    2     19     eft.txt eftdo eftdc
    3     40     The jar file is not found: Encryptor.jar
    4     44     External program terminated with exit code 1
    and  do not give any output.
    please  help.
    Thanks & regards
    SS

    report zsrchsap.
    *-This is a demo report for Search Sap
    *-Author : Sandeep Kulkarni
    *-Date : 09/20/2001
    parameters : p_sfile(60) lower case
              "File to be moved
              "Eg : /home/in/SFILE1.txt
                p_dfile(60) lower case.
              "File's Destination
              "Eg: /home/archive/SFILE1.txt
    data : t_btcxpm
           like btcxpm occurs 0,
           p_addparam
           like sxpgcolist-parameters.
      concatenate
      '/home/ABAP/scripts/Archive_file.sh'
      p_sfile
      p_dfile
      into p_addparam separated by space.
      refresh t_btcxpm. clear t_btcxpm.
      call function 'SXPG_CALL_SYSTEM'
        exporting
          commandname = 'ZSHELL'
          additional_parameters = p_addparam
        tables
          exec_protocol = t_btcxpm
        exceptions
          no_permission              = 1
          command_not_found          = 2
          parameters_too_long        = 3
          security_risk              = 4
          wrong_check_call_interface = 5
          program_start_error        = 6
          program_termination_error  = 7
          x_error                    = 8
          parameter_expected         = 9
          too_many_parameters        = 10
          illegal_command            = 11
          others                     = 12.
      if sy-subrc = 0.
        write : /
        'File',p_sfile,'moved to',p_dfile.
      else.
        write : / 'Error Occured'.
      endif.

  • Call unix commands from stored procedures

    My stored procedure requires to call unix commands HOW DO I DO IT?
    null

    i do not know pl sql but in java you can use:
    Runtime.getRuntime().exec("YOUR UNIX COMMAND");
    real example:
    Runtime.getRuntime().exec("ls");
    but you must be careful with using that...
    especially if you want to wait till the process finishes..
    rgds,

  • Calling DTS package from Stored Procedure

    I am getting error calling DTS package from CF.
    So i want to call DTS package from SQL Server Stored
    Procedure.
    DTS package create text file. So no need of input or output
    parameter.
    What is the syntax?.
    thanks for ur help.

    Ted Kruger explains how this can be done in his blog post
    Run SSIS Package from Stored Procedure
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog

  • System command execution from stored procedure

    Hello World,
    How to run System command from stored procedure ?
    For example :
    Delete a file
    running a programm,
    Is it possible ?
    H.M

    Years ago I did this by writing an output file with commands into a directory and had a cron job looking for this file. At the end of the run the file was removed.
    Never checked if there are other possibilities nowadays.
    cu
    Andreas

  • Executing Unix scripts from a stored procedure

    From the sql*plus windows, I am able to execute the host command and '!sh' commands; but I need to ececute Unix scripts from a stored procedure. Hoe can I do this? Where can I get good documentation on this? Any help would be greatly appreciated!
    Thanks..

    Hi,
    U can use external procedure ( newly added feature in 8.0.3 onwards) and call any shared library. From shared library u can execute it.
    One sql command is there HOST(' '). U can run a OS command. But u can not use it in PL/SQL.
    U can call pls sql from shell !!!!!..
    Thanks...
    Boby Jose

  • Run multiple unix commands from ODI procedure

    I want to run a series of unix commands from ODI procedure. I dont want to use Unix shell scripts. (I know that works).I am just trying to place the contents of the shell scripts in ODI procedure with Operating system as technology. But I am unable to execute the proecedure.
    For example below is a very small 3 line commands I would execute
    filename="/var/test.txt"
    ls -l $filename > /var/anotherfile.txt
    chmod 777 $filename
    I am not sure if there is any specific syntax that I have to follow for executing unix commands. Also I dont want to write a Jython and use os.system command as well.
    Appreciate any help on this

    First your original question... You can put more than one DOS command on a single line, simply separate each command with an ampersand (&). For example:
    mkdir c:\abc & cd abc & dir*
    Regarding your concerns about performance, well that would depend on exactly what you mean. Using CLIENT_HOST (or HOST on the server) simply opens a shell (DOS in this case) then passes your command to it. The performance of performing this action really isn't measurable. Basically you are just pressing a button and you should get a near immediate action. As for the performance of executing each command, that has nothing to do with Forms. Once the command is passed to the shell, the rest is a function of the shell and whatever command you passed.
    Having said that, if you were to write something sloppy like a loop (in pl/sql) which called CLIENT_HOST lots of times repeatedly, then yes there would be a performance problem because the pushing of the button will cause an exchange to and from the server and each cycle in the loop will do the same.
    So the answer to how performance is impacted will depend on what exactly you need to accomplish. If it is a single call to CLIENT_HOST, this should be fine.

  • Running a Unix script from a Java class

    I am trying to use SCP (Secure copy) to copy an xml file from my J2EE application to a remote Unix server using a Unix script. How can I run the Unix script from my Java class? I could not find any resource for this on the internet. Can someone help me with this please.
    Thanks

    I am trying this below program ,but i am getting the error please help me
    import com.jcraft.jsch.*;
    import com.jcraft.jsch.Channel;
    import com.jcraft.jsch.JSch;
    //import com.jcraft.jsch.JSchException;
    import com.jcraft.jsch.Session;
    //import com.jcraft.jsch.UserInfo;
    import java.io.*;
    public class testrad {
    public static void main(String args[])
    String user="usertvr";
    String host="5.34.12.1";
    String cmd="ls -l";
    JSch jsch = new JSch();
    try{
    Session session=jsch.getSession(user,host,22);
    session.setPassword("$yhaj23");
    //UserInfo usrInfo=new MyUserInfo();
    //session.setUserInfo(usrInfo);
    session.connect();
    Channel channel=session.openChannel("exec");
    ((ChannelExec) channel).setCommand(cmd);
    channel.setXForwarding(true);
    channel.connect();
    //code
    channel.setInputStream(System.in);
    // channel.setOutputStream(System.out);
    //((ChannelExec) channel).setErrStream(System.err);
    InputStream in = channel.getInputStream();
    channel.connect();
    byte[] tmp = new byte[1024];
    while (true)
    while (in.available() > 0)
    int i = in.read(tmp, 0, 1024);
    if (i < 0)
    break;
    System.out.print(new String(tmp, 0, i));
    if (channel.isClosed())
    in.close();
    // System.out.println("JSCH: exit-status: " +
    //channel.getExitStatus());
    break;
    try
    Thread.sleep(1000);
    catch (Exception ee)
    channel.disconnect();
    session.disconnect();
    }catch(Exception e)
    {e.printStackTrace();
    System.out.println("Exception"+e);}
    /*public static class MyUserInfo implements UserInfo {
    public String getPassword()
    { return "password"; }
    public String getPassphrase()
    { return ""; }
    public boolean promptPassword(String arg0)
    { return true; }
    public boolean promptPassphrase(String arg0)
    { return true; }
    public boolean promptYesNo(String arg0)
    { return true; }
    public void showMessage(String arg0)
    Here is the error
    com.jcraft.jsch.JSchException: UnknownHostKey: 5.128.0.10. RSA key fingerprint is 02:a0:d6:c0:6f:69:2c:a9:a7:fa:7c:71:1c:60:ed:57
         at com.jcraft.jsch.Session.checkHost(Unknown Source)
         at com.jcraft.jsch.Session.connect(Unknown Source)
         at com.jcraft.jsch.Session.connect(Unknown Source)
         at testrad.main(testrad.java:23)
    Exceptioncom.jcraft.jsch.JSchException: UnknownHostKey: 5.128.0.10. RSA key fingerprint is 02:a0:d6:c0:6f:69:2c:a9:a7:fa:7c:71:1c:60:ed:57
    Can some one help me please.
    I running this program from Windows to connect to remote unix boxes.

  • Run a UNIX Script from java

    Hi,
    how can i run a unix script from java application. This java application is on windows.
    How can i do this.
    thanks,

    Hi,
    how can i run a unix script from java application.
    This java application is on windows.
    So I think it's safe to assume that the target script is on a remote unix server.
    Take a look at http://sourceforge.net/projects/sshtools/

Maybe you are looking for

  • How to create a folder in mac os x (10.5.x) with director 11.5

    hi: i'm using FileXtra4 in windows and it's work perfect, when i try it in mac os x, director tell me 'Script Xtra not found' this xtra file is in de Xtra folder and i don't now what's happened. i need create a folder for save a historial file of use

  • Can't transfer files from tower to laptop

    I have a G4 sawtooth tower connected to a Netgear wireless router MR814v2. 2 G4's ( both OS 10.3.9) are connected to the router by ethernet cable and a PC laptop has a Netgear wireless card that also connects it. The 2 G4's share internet, file shari

  • The most frequent site is not at top of list on location bar dropdown in 10.0.2

    Previous version ordered the drop down history on locator bar by frequency of use. This meant my most commonly visited site was at top of list and I used that to select my site. Now it's halfway down the history list and more inconvenient to access.

  • Accessing the filesystem

    Is it possible to acces the real filesystem (not a vfs) through libc with abode air? Even if this do not work for a release build that would be nice. I am trying to setup a dev environement with Lua, but each time I change my assets I have to compile

  • Re: Material Deletion

    Hi, I have one scenario which i need your expertise advise, that is material was created as make-part in GUE1, however due to some reason, we don't assemble this pump model here in GSI, but we counter-offer the alternative pump model to customer inst