How to call Operating System commands / external programs from within APEX

Hi,
Can someone please suggest how to call Operating Systems commands / external programs from within APEX?
E.g. say I need to run a SQL script on a particular database. SQL script, database name, userid & password everything is available in a table in Oracle. I want to build a utility in APEX where by when I click a button APEX should run the following
c:\oracle\bin\sqlplusw.exe userud/password@database @script_name.sql
Any pointers will be greatly appreciated.
Thanks & Regards,

Hi Guys,
I have reviewed the option of using scheduler and javascript and they do satisfy my requirements PARTIALLY. Any calls to operating system commands through these features will be made on the server where APEX is installed.
However, here what I am looking at is to call operating systems programs on client machine. For example in my APEX application I have constructed the following strings of commands that needs to be run to execute a change request.
sqlplusw.exe user/password@database @script1.sql
sqlplusw.exe user/password@database @script2.sql
sqlplusw.exe user/password@database @script3.sql
sqlplusw.exe user/password@database @script4.sql
What I want is to have a button/link on the APEX screen along with these lines so that when I click that link/button this entire line of command gets executed in the same way it would get executed if I copy and paste this command in the command window of windows.
Believe me, if I am able to achieve what I intend to do, it is going to save a lot of our DBAs time and effort.
Any help will be greatly appreciated.
Thanks & Regards,

Similar Messages

  • How to call operating system commands?

    Can we call OS commands from JAVA?
    I am trying to call lpr/lp commands from JAVA.
    Can anybody guide me where to search for this information.
    Thanks in advance
    Srini

    Thanks for you all for this information. I will try this....Your information greatly helped me to go forward...

  • Is it possible to call operating system command after file receive?

    Hi expert,
    I'm trying to call operating system command after file receive comm.channel receive a txt file.
    operating system command uses txt file name as parameter.
    Is it possible? How?
    Thanks.

    Hi,
    It should be possible, actually we have two options that are
    1.RUN OS command before message processing
    2.RUN OS command after message processing.
    So you can give the commands in the RUN OS command after message processing.
    Check this links for more info
    http://wiki.sdn.sap.com/wiki/display/XI/SAP%20XI%20File%20Adapter%20OS%20Command%20Line%20Feature
    http://help.sap.com/saphelp_nwpi71/helpdata/en/44/556cb799c93677e10000000a114a6b/content.htm
    http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417200)ID1690747750DB11724434094963199241End?blog=/pub/wlg/10392
    Regards
    Ramesh

  • How to execute Operating System commands from Stored procedure.

    Any help on how to execute Operating System commands from stored procedures will be appreciated.
    Nanditha.

    Search the forums for 'External Procedure' and you will find example code that has been posted before.

  • How to use Operating System Commands while using define in sqlplus

    How to use Operating System Commands while using define in sqlplus . The Host OS is Linux
    define report_name=PROD_${host date "+%b"}.html
    The above is not working.
    The output should be 
    define report_name=PROD_JAN.html
    Regards,
    DB

    of course I was talking nonsense: the problem here is the mixing of bind variables and DEFINE variables.
    With the following changes the script should work (the conditions for begin_interval_time are perhaps not what you want):
    variable snap1 number
    variable snap2 number
    variable rptname varchar2(20)
    begin
    SELECT min(snap_id) into :snap1 FROM dba_hist_snapshot WHERE CAST(begin_interval_time AS DATE) >= SYSDATE-1;
    SELECT max(snap_id) into :snap2 FROM dba_hist_snapshot WHERE CAST(begin_interval_time AS DATE) >= SYSDATE-1;
    end;
    col file_name_value new_value report_name noprint
    select 'PROD_'|| to_char(sysdate,'MON') || '_' ||  to_char(sysdate,'DD') file_name_value  from dual;
    define  report_type  = 'html'
    define num_days=2
    define begin_snap=:snap1
    define end_snap=:snap2
    @@?/rdbms/admin/awrrpt.sql

  • Calling Operating System Commands from PL/SQL using java

    Calling Operating System Commands from PL/SQL - The Java Way
    wlth help of given thread link,
    Calling OS Commands from Plsql
    but i had user privilege problem
    Declare
    x Varchar2(2000);
    Begin
    x := OSCommand_Run('/tmp/sri/GROUP_ho.sh');
    DBMS_OUTPUT.Put_Line(x);
    End;
    o/p;
    can't exec: /tmp/sri/GROUP_ho.sh lacks user privilege
    i done the grant privillage also
    part
    dbms_java.grant_permission('abcd', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
    dbms_java.grant_permission('abcd', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
    dbms_java.grant_permission('
    abcd', 'SYS:java.io.FilePermission','<<ALL FILES>>', 'execute');
    again
    get
    can't exec: /tmp/sri/GROUP_ho.sh lacks user privilege
    same error;

    Process management at the OS level should prevent execution continuing in the calling code until the command has completed (either successfully or with error).
    If the low level java code were to spawn child process threads then execution could continue, but I'm guessing the Java function your talking about doesn't do that and just calls the operating system to execute the command and waits for the returning code to come back.

  • How to: execute operating system commands from PL/SQL

    System: IBM pSeries AIX
    Oracle: 11g Enterprise
    Is there a quick way to execute operating system commands from PL/SQL?
    Without creating a JAVA class....
    I need to execute a Loader script.
    I want to do this from within PL/SQL.
    I need to to do 4 things.
    Three require SQL scripts.
    The fourth is SQL*Loader.
    The usual way is with a UNIX script calling 3 SQL scripts and one Loader control file.
    Is there way to do all this from within ONE PL/SQL SCRIPT ??
    Just let me know.

    Is there a quick way to execute operating system commands from PL/SQL?
    NO
    Without creating a JAVA class....
    I need to execute a Loader script.
    I want to do this from within PL/SQL.
    WHY ON EARTH, such action will create a new connection and become a resource hog?
    I need to to do 4 things.
    Three require SQL scripts.
    The fourth is SQL*Loader.
    The usual way is with a UNIX script calling 3 SQL scripts and one Loader control file.
    Which is perfect for the purpose.
    Is there way to do all this from within ONE PL/SQL SCRIPT ??
    Just let me know.
    NO, there is NOT. Nor should there be. Why create unstable ineffcient Mickey Mouse systems, glued together by hacking?
    Sybrand Bakker
    Senior Oracle DBA

  • How to execute operation system commands by using TSQL without enabling xp_cmdshell.

    Hi Experts
    Looking for advise if one can use operation system commands using TSQL without enabling xp_cmdshell. 
    actually using xp_cmdshell requires sysadmin privs which I am unable to provide (directly or using proc) to a user  but the user needs some operating system commands to execute for file manipulation from sql server session. Please share your thought.
    Best Regards 
    khalil

    >but the user needs some operating system commands to execute for file manipulation from sql server session
    See article here
    http://www.mssqltips.com/sqlservertip/2014/replace-xpcmdshell-command-line-use-with-sql-server-agent/:
    "Problem
    I need to run something from the command-line, but based on best practices xp_cmdshell has been disabled. The task that needs to run is an internal process that will originate from within SQL Server. Is there a way to do this without using xp_cmdshell?
    Solution
    The use of xp_cmdshell is generally frowned upon and is now recommended to be disabled, unless it is absolutely necessary.  There is a solution that works around this restriction via the use of SQL Server Agent.
    Wherever SQL Server is installed, SQL Server Agent is installed with it (except for SQL Express). SQL Server Agent has the ability to run job steps which invoke the command shell. And in the case that the job is owned by a member of the sysadmin fixed server
    role, the job will execute as the service account under which the SQL Server Agent is running. "
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Database Design
    New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014

  • How to Run Operating System Command Before/After Message Processing SAP PI

    Hi,
    We are trying to execute multiple commands via "Operating System Command Before/After Message Processing".
    When we use single command say for example cp or mv (copy or move) the commands get executed fine.
    eg: cp %F /var/opt/data/outbound/Test/Dummy.txt 
    /this works fine/
    when we club commands together or try to redirect the outputs of commands, none of the commands get executed.
    eg:
    cp %F /var/opt/data/outbound/Test/Dummy.txt ; rm %F
    or
    wc -l %F > /var/opt/data/outbound/Test/Dummy.txt
    Is it possible to execute multiple commands or redirect the output  of commands without using a shell script? The PI server we are working on iis hosted on UNIX environment.

    Hi Harleen,
    try like this
    cp %F /var/opt/data/outbound/Test/Dummy.txt ; rm %F
    instead of semicolon try this
    (1) &
    command1 & command2
    Execute Command1 and then execute Command2
    (2) &&
    command1 && command2
    Runs the command2 only when command1 doesn't Complete successfully
    (3) ||
    command1 || command2
    Runs the second command if the first command had an error
    (4) ()
    (command1 || command2) || (command3 & command4)
    Defines the order in which commands are to be executed
    Regards
    Suraj

  • How can I execute an external program from within a button's event handler?

    I am using Tomcat ApacheTomcat 6.0.16 with Netbeans 6.1 (with the latest JDK/J2EE)
    I need to execute external programs from an event handler for a button on a JSF page (the program is compiled, and extremely fast compared both to plain java and especially stored procedures written in SQL).
    I tried what I'd do in a standalone program (as shown in the appended code), but it didn't work. Instead I received text saying the program couldn't be found. This error message comes even if I try the Windows command "dir". I thought with 'dir' I'd at least get the contents of the current working directory. :-(
    I can probably get by with cgi on Apache's httpd server (or, I understand tomcat supports cgi, but I have yet to get that to work either), but whatever I do I need to be able to do it from within the button's event handler. And if I resort to cgi, I must be able to maintain session jumping from one server to the other and back.
    So, then, how can I do this?
    Thanks
    Ted
    NB: The programs that I need to run do NOT take input from the user. Rather, my code in the web application processes user selections from selection controls, and a couple field controls, sanitizes the inoputs and places clean, safe data in a MySQL database, and then the external program I need to run gets safe data from the database, does some heavy duty number crunching, and puts the output data into the database. They are well insulated from mischeif.
    NB: In the following array_function_test.pl was placed in the same folder as the web application's jsp pages, (and I'd tried WEB-INF - with the same result), and I DID see the file in the application's war file.
            try {
                java.lang.ProcessBuilder pn = new java.lang.ProcessBuilder("array_function_test.pl");
                //pn.directory(new java.io.File("K:\\work"));
                java.lang.Process pr = pn.start();
                java.io.BufferedInputStream bis = (java.io.BufferedInputStream)pr.getInputStream();
                String tmp = new String("");
                byte b[] = new byte[1000];
                int i = 0;
                while (i != -1) {
                    bis.read(b);
                    tmp += new String(b);
                getSelectionsDisplayTextArea().setText(getSelectionsDisplayTextArea().getText() + "\n\n" + tmp);
            } catch (java.io.IOException ex) {
                getSelectionsDisplayTextArea().setText(getSelectionsDisplayTextArea().getText() + "\n\n" + ex.getMessage());
            }

    Hi Fonsi!
    One way to execute an external program is to use the System Exec.vi. You find it in the functions pallet under Communication.
    /Thomas

  • Calling external programs from within a Tomcat application

    I've got a fairly complex existing Tomcat application (which is packaged and built as a .war file) which I'm trying to edit so that it calls a Perl script part way through the processing, which will generate an XML file used later on. I think I've worked out how to call external scripts from within Java, but at the moment when I try and access the application via Tomcat the application either hangs or bails out (I don't know which, as the log files unhelpfully don't give any error messages).
    The code which is causing the problem looks like this:
    System.err.println("Calling runtime...");
    Runtime runtime = Runtime.getRuntime();
    System.err.println("Executing process...");
    Process process = runtime.exec("/path/to/ysearch.pl 'News' '\"search query\"' 'file");
    System.err.println("Waiting for process...");
    int exitVal = process.waitFor();
    System.out.println("Exited with error code: " + exitVal);The code gets as far as "Executing process..", beyond that there is nothing in the log file so I presume the runtime.exec() call is where the problem is. I'm not interested in reading the output from the script (there shouldn't be any), so that's not an issue, and the permissions on it allow anyone to read or execute ysearch.pl so I don't think there's a problem in that area.
    Does anyone have any suggestions which I could try to get this to work? I've only been using Tomcat for a week (I'm picking up on someone else's code) so I might have made a beginner's mistake. I'm using Tomcat 5 on Fedora Core 7, and Java 1.5.0_01 (I can't easily change any of those).

    I'm not sure, but I thing that overhead caused by calling du cannot be big enough to matter even on older machines.
    But, when calling du from Perl script you are also invoking shell, and this can be a little bit more 'heavy'.

  • How to call operating system(windows) functions like sutdown,refresh,et

    Hello,
    I am new in Oracle D2k.I want to know that how to call windows XP/7 shell commands(operating system functions) or windows function key(like F5 for system refresh in windows xp/7) in an Oracle Form.
    Actually I have to make a trigger which can fire at pressing a particular key and execute appropriate action of Windows7 like shutdown,F5(function key of windows to system refresh).
    thank you
    regards
    aaditya.

    Just for future reference, regardless if you are posting in the Forms area of the forum or any other, terms like Forms 11g, Oracle 11g, etc are parts of product names. They are not version numbers although they do offer a slight hint. It is very important that when posting you include the complete version number of any products related to the problem or question you have. For example, you said you are using Oracle Forms 11g. Look at how many possible versions "Forms 11g" could possibly be:
    11.1.1.1
    11.1.1.2
    11.1.1.3
    11.1.1.4
    11.1.1.6
    11.1.2.0
    11.1.2.1
    With each new patch release and major release, a large number of bug fixes are included. In the case of new major releases, in addition to bug fixes, many new features are added. So knowing the version number is important.
    Beyond that, it would appear that you have many questions:
    1. How to copy and paste
    2. How to execute a system shutdown
    3. How to force the browser into full screen mode
    4. Refresh - this one is unclear. What do you mean by "refresh"?
    Let me answer those that I can:
    <blockquote>o Functions like cut/copy/paste are available directly from your Forms code. For these I would recommend referring to the Builder's Online Help. Look for CUT_REGION, COPY_REGION, PASTE_REGION. It might also be helpful to understand SELECT_ALL. For example you may want to code a Copy button like this:
    GO_ITEM('some_text_field);
    SELECT_ALL;
    COPY_REGION;o To execute a system shutdown on the client machine, you would first need to WebUtil enable your form. Refer to the Forms Builder Online Help for information about how to use WebUtil. You can also find lots of information in this forum about WebUtil. Once enabled, you can execute a Windows shutdown in various ways. Here one option:
    Declare
         my_cmd varchar2(255);
    Begin
         my_cmd := 'cmd /c start "" "' || '"shutdown -s -f -t 1"' || '"';
         WEBUTIL_HOST.HOST (my_cmd);
    End;Refer to the Microsoft documentation for more information: http://technet.microsoft.com/en-us/library/bb491003.aspx
    o I'm not sure what you are attempting to do with the F11. I understand that this function key sets the browser to full screen, but the form will not exactly adjust for this change in browser size. You can adjust the applet size dynamically, but not the form. For that you would need to code the behavior yourself. So, before I can offer something specific, it would be helpful to understand what you expectation is and if what you want is to set the browser to full screen, why not just allow the end user to do it? You could easily have a java script popup displayed before the form starts which might say something like "To maximize your browser, press F11"
    o Finally, "refresh". I don't know what you mean here. Refresh what? The Windows desktop, browser, Oracle Forms.....
    </blockquote>

  • Calling  Operating system command  from PL/SQL programs

    Hi
    Is there any way we call the unix shell script from PL/SQL procedure/functions

    In 10g, it is possible.
    BEGIN
    dbms_scheduler.create_job(job_name => 'myjob',
    job_type => 'executable',
    job_action => '/app/oracle/x.sh',
    enabled => TRUE,
    auto_drop => TRUE);
    END;
    SQL> exec dbms_scheduler.run_job('myjob');
    Documentation:
    http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sched.htm#sthref6596
    -aijaz

  • Help! How to call Unix system command?

    In my java application.there are some code as following:
    try{
    String cmd = "ls -a > temp.txt";
    Runtime runtime = Runtime.getRuntime();
    Process process = runtime.exec(cmd);
    int rc = process.exitValue();
    if (rc == 0){
    System.out.println("OK!");
    else{
    System.out.println("Failed!");
    catch(Exception ex){
    ex.printStackTrace();
    But when i run the application, it always throws IllegalTreadStateException,
    return code(rc) is 2, exception's content is as below:
    java.lang.IllegalThreadStateException: process hasn't exited
    at java.lang.UNIXProcess.exitValue(UNIXProcess.java:118)
    at MyApplication.main(...)
    If someone know what happened, please help me, my E-mail address is:
    [email protected]

    import java.io.*;
    public class RunCommand {
    public static void main(String args[]) {
    String s = null;
    try {
         // run the Unix "ps -ef" command
    Process p = Runtime.getRuntime().exec("ps -ef");
    BufferedReader stdInput = new BufferedReader(new
    InputStreamReader(p.getInputStream()));
    BufferedReader stdError = new BufferedReader(new
    InputStreamReader(p.getErrorStream()));
    // read the output from the command
    System.out.println("Here is the standard output of the command:\n");
    while ((s = stdInput.readLine()) != null) {
    System.out.println(s);
    // read any errors from the attempted command
    System.out.println("Here is the standard error of the command (if any):\n");
    while ((s = stdError.readLine()) != null) {
    System.out.println(s);
    System.exit(0);
    catch (IOException e) {
    System.out.println("exception happened - here's what I know: ");
    e.printStackTrace();
    System.exit(-1);
    http://www.devdaily.com/java/edu/pj/pj010016/index.shtml
    Cheers,
    Bala

  • How can I forward to an external URL from within a DataAction?

    This is a very simple question I'd guess -- but what I thought was the obvious answer turned out not to be. Keep in mind I am using struts, and the URL is constructed dynamically, so I cannot place a struts forward action in the struts-config.xml file. Here is what I tried from within my DataAction's prepareModel() method:
    actionContext.setActionForward(newURL);
    actionContext.setRedirect(true);
    This didn't work -- nothing happened. Anyone have any ideas?
    Brad

    In our application, we had a forward named Cancel, but for it to work properly we wanted a Redirect to occur to another page. The redirect was not working until we created a new actionforward and set th action forward to it as seen below. You can't programmatically change the forwards at runtime without error, from what I remember.
    DataActionMapping mapping = ctx.getActionMapping();
    ActionForward af = mapping.findForward("Cancel");
    ActionForward afNew = new ActionForward();
    afNew.setPath(ctx.getHttpServletRequest().getSession().getServletContext().getInitParameter("rootURL") + af.getPath());
    afNew.setRedirect(true);
    ctx.setActionForward(afNew);

Maybe you are looking for

  • 11.5.10.2 Fresh install - NLS problem

    Hi all, I'm doing a multinode fresh install of 11.5.10.2 on HP-UX. Came across the following from rapidwiz (it only happens with Simplified Chinese): RW-50004: Error code received when running external process. Check log file for details. Running APP

  • How to delete entries in an internal table except for one entry

    Hi all, I have 4 records in my internal table and I need to delete all the  records in the internal table except the last one.How do i do this?Any sample code? Thanks. Moderator message - Please do not ask or answer basic questions - thread locked Ed

  • Why can't I sign in with my snapfish account?

    I can't sign in to ePrint.  I have a snapfish account ([Personal Information Removed]) but it doesn't work.  I can't create an account, because it says one already exists with my email.  When I ask it to send my password, it asks me to type in my ema

  • Need documents on SEM-CPM

    Guys, I am actually looking for <b>SEM-CPM</b> related pdf documents. Can anyone provide me please? Points are assured.... Sirish.

  • Why is Lightroom 5 hanging when trying to export images?

    Why is Lightroom 5 hanging when trying to export images?