Incorporate shell commands from forms

How to incorporate unix shell commands(eg. ls, cp) from forms9i?
In Windows environment,it is possible by issuing
host command(eg. HOST('DIR >k.lis') -- it moves the list of files from Oracle9i/forms90 path to a file k.lis).
The same thing I have to do in a unix environment.

I think you have the wrong forum. This forum has to do
with the UIX technology inside of JDeveloper. Your
question seems to have to do with UNIX or forms. I can't
tell which.

Similar Messages

  • Execute shell command from within pascal code

    Hello there,
    I am trying to execute a shell command from within my pascal code. I use XCode together with FreePascal. I have tried something like:
    exec ('program', 'options');
    adding the 'Dos' unit to the Uses clause of my program.
    Thus, e.g.,
    exec ('mkdir', '/A')
    to create a directory with the name 'A'.
    However, my attempts so far were unsuccessful. Can anyone help me on this, and perhaps provide a simple example of how to do it right?
    Thank you in advance,
    Shane

    In the mean time, I found the problem myself. I am just posting the solution here for anyone that is interested. My original solution was correct, in that the 'Dos' Unit must be added, and that the right command is 'exec'. There was however a problem with the correct path to the program that I wanted to invoke. In the shell, this program was accessible from anywhere. However, in the 'exec' command, the full path to the program must be given. Since I am not a Unix expert, I don't know the reason for this.
    So, in summary, the solution is:
    Uses Dos;
    begin
    exec ('full path to program', 'program options');
    e.g.: exec ('/bin/sh', '/run.sh') to process the commands in the file /run.sh
    end
    Hope this may be of help to anyone else.
    Shane
    Mac OS X (10.3.9)
    Mac OS X (10.3.9)
    Mac OS X (10.3.9)

  • Execute shell command from Java

    Hi all,
    I need some idea for executing shell script from Java programe.
    For example i have start.sh script in /tmp/start.sh  folder of unix server.
    I want to execute shell script from local java code.
    Any idea on this.

    Hi,
           Read the following articles/posts, maybe this could help you:
          How to execute shell command from Java
    Running system commands in Java applications | java exec example | alvinalexander.com
    Want to invoke a linux shell command from Java - Stack Overflow

  • How to Execute Power Shell Command From Windows Application.

    Hi All Experts,
    I want to execute power shell commands from my windows application.
    Is it possible ?
    Please let me know your comments..
    Thanks.

    I have not tried this, but apprently it is easy as in the sample pasted below. please see this article for more details
    http://geekswithblogs.net/Norgean/archive/2012/09/19/running-powershell-from-within-sharepoint.aspx.
    Let me know how it goes...
    public string RunPowershell(string powershellText, SPWeb web, string param1, string param2) {
    // Powershell ~= RunspaceFactory - i.e. Create a powershell context
    var runspace = RunspaceFactory.CreateRunspace();
    var resultString = new StringBuilder();
    try
    // load the SharePoint snapin - Note: you cannot do this in the script itself (i.e. add-pssnapin etc does not work)
    PSSnapInException snapInError;
    runspace.RunspaceConfiguration.AddPSSnapIn("Microsoft.SharePoint.PowerShell", out snapInError);
    runspace.Open();
    // set a web variable.
    runspace.SessionStateProxy.SetVariable("webContext", web);
    // and some user defined parameters
    runspace.SessionStateProxy.SetVariable("param1", param1);
    runspace.SessionStateProxy.SetVariable("param2", param2);
    var pipeline = runspace.CreatePipeline();
    pipeline.Commands.AddScript(powershellText);
    // add a "return" variable
    pipeline.Commands.Add("Out-String");
    // execute!
    var results = pipeline.Invoke();
    // convert the script result into a single string
    foreach (PSObject obj in results)
    resultString.AppendLine(obj.ToString());
    finally
    // close the runspace
    runspace.Close();
    // consider logging the result. Or something.
    return resultString.ToString();
    Ok. We've written some code. Let us test it.
    var runner = new PowershellRunner();
    runner.RunPowershellScript(@"
    $web = Get-SPWeb 'http://server/web' # or $webContext
    $web.Title = $param1
    $web.Update()
    $web.Dispose()
    ", null, "New title", "not used");
    -Sangeetha

  • Shell commands from JSP after Forms migration

    During application migration from forms 9i to JSP & BC4J, I have to code the following Forms code into my JSP application.This is for a button pressed trigger.
    DECLARE
    RENAME_STRING VARCHAR2(120):= 'RENAME C:\BRC\PDATA' ||:DRAWING_ACCOUNTS.ACCOUNT_ID|| '.TXT P' || :DRAWING_ACCOUNTS.ACCOUNT_ID || TO_CHAR(SYSDATE,'DDMMYY')|| '.txt';
    BEGIN
    HOST( RENAME_STRING, no_screen );
    web.show_document( 'http://hostname/selectfile.html', '_new');
         IF NOT Form_Success THEN
              Message('Error -- File not Renamed.');
         END IF;
    END;
    How can I do this simple sending of OS commands in JSP, any ideas?

    Hi,
    Not only rename commands but I have to pass several other os commands like 'sqlldr' for data upload as well. Therefore, I need a reusable piece of code for that. I have acheived some way for that using the following code.
    put the following file in that package.
    package BankrecBC4J;
    import java.util.*;
    import java.io.*;
    import java.net.*;
    import java.text.*;
    import java.util.zip.*;
    class StreamGobbler extends Thread
    InputStream is;
    String type;
    StreamGobbler(InputStream is, String type)
    this.is = is;
    this.type = type;
    public void run()
    try
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);
    String line=null;
    while ( (line = br.readLine()) != null)
    System.out.println(type + ">" + line);
    } catch (IOException ioe)
    ioe.printStackTrace();
    public class GoodWindowsExec
    private static final boolean NATIVE_COMMANDS = true;
    //Allow browsing and file manipulation only in certain directories
         private static final boolean RESTRICT_BROWSING = false;
    //If true, the user is allowed to browse only in RESTRICT_PATH,
    //if false, the user is allowed to browse all directories besides RESTRICT_PATH
    private static final boolean RESTRICT_WHITELIST = false;
    //Paths, sperated by semicolon
    //private static final String RESTRICT_PATH = "C:\\CODE;E:\\"; //Win32: Case important!!
         private static final String RESTRICT_PATH = "/etc;/var";
         * Command of the shell interpreter and the parameter to run a programm
         private static final String[] COMMAND_INTERPRETER = {"cmd", "/C"}; // Dos,Windows
         //private static final String[] COMMAND_INTERPRETER = {"/bin/sh","-c"};      // Unix
         * Max time in ms a process is allowed to run, before it will be terminated
    private static final long MAX_PROCESS_RUNNING_TIME = 30 * 1000; //30 seconds
         //Normally you should not change anything after this line
         //Change this to locate the tempfile directory for upload (not longer needed)
         private static String tempdir = ".";
         private static String VERSION_NR = "1.1a";
         private static DateFormat dateFormat = DateFormat.getDateTimeInstance();
    public GoodWindowsExec(String g)
    System.out.println(" hello " + g);
    /*if (g.length < 1)
    System.out.println("USAGE: java GoodWindowsExec <cmd>");
    System.exit(1);
    try
    String osName = System.getProperty("os.name" );
    String[] cmd = new String[3];
    System.out.println("here ");
    if( osName.equals( "Windows NT" ) )
    cmd[0] = "cmd.exe" ;
    cmd[1] = "/C" ;
    cmd[2] = g;
    else if( osName.equals( "Windows 2000" ) )
    System.out.println("Windows 2000");
    cmd[0] = "command.com" ;
    cmd[1] = "/C" ;
    cmd[2] = g;
    else if( osName.equals( "Windows XP" ) )
    System.out.println("Windows XP");
    cmd[0] = "command.com" ;
    cmd[1] = "/C" ;
    cmd[2] = g;
    else if( osName.equals( "Windows 95" ) )
    cmd[0] = "command.com" ;
    cmd[1] = "/C" ;
    cmd[2] = g;
    Runtime rt = Runtime.getRuntime();
    System.out.println("Execing " + cmd[0] + " " + cmd[1]
    + " " + cmd[2]);
    Process proc = rt.exec(cmd);
         * Starts a native process on the server
         *      @param command the command to start the process
         *     @param dir the dir in which the process starts
    // any error message?
    StreamGobbler errorGobbler = new
    StreamGobbler(proc.getErrorStream(), "ERROR");
    // any output?
    StreamGobbler outputGobbler = new
    StreamGobbler(proc.getInputStream(), "OUTPUT");
    // kick them off
    errorGobbler.start();
    outputGobbler.start();
    // any error???
    int exitVal = proc.waitFor();
    System.out.println("ExitValue: " + exitVal);
    } catch (Throwable t)
    t.printStackTrace();
         * Converts some important chars (int) to the corresponding html string
         static String conv2Html(int i) {
              if (i == '&') return "&amp;";
              else if (i == '<') return "&lt;";
              else if (i == '>') return "&gt;";
              else if (i == '"') return "&quot;";
              else return "" + (char) i;
    static String startProcess(String command, String dir) throws IOException {
              StringBuffer ret = new StringBuffer();
              String[] comm = new String[3];
              comm[0] = COMMAND_INTERPRETER[0];
              comm[1] = COMMAND_INTERPRETER[1];
              comm[2] = command;
              long start = System.currentTimeMillis();
              try {
                   //Start process
                   Process ls_proc = Runtime.getRuntime().exec(comm, null, new File(dir));
                   //Get input and error streams
                   BufferedInputStream ls_in = new BufferedInputStream(ls_proc.getInputStream());
                   BufferedInputStream ls_err = new BufferedInputStream(ls_proc.getErrorStream());
                   boolean end = false;
                   while (!end) {
                        int c = 0;
                        while ((ls_err.available() > 0) && (++c <= 1000)) {
                             ret.append(conv2Html(ls_err.read()));
                        c = 0;
                        while ((ls_in.available() > 0) && (++c <= 1000)) {
                             ret.append(conv2Html(ls_in.read()));
                        try {
                             ls_proc.exitValue();
                             //if the process has not finished, an exception is thrown
                             //else
                             while (ls_err.available() > 0)
                                  ret.append(conv2Html(ls_err.read()));
                             while (ls_in.available() > 0)
                                  ret.append(conv2Html(ls_in.read()));
                             end = true;
                        catch (IllegalThreadStateException ex) {
                             //Process is running
                        //The process is not allowed to run longer than given time.
                        if (System.currentTimeMillis() - start > MAX_PROCESS_RUNNING_TIME) {
                             ls_proc.destroy();
                             end = true;
                             ret.append("!!!! Process has timed out, destroyed !!!!!");
                        try {
                             Thread.sleep(50);
                        catch (InterruptedException ie) {}
              catch (IOException e) {
                   ret.append("Error: " + e);
              return ret.toString();
    In the first line of the JSP file include the package
    <%@page import="BankrecBC4J.*" %>
    and call
    it this way:from the jsp page
    new GoodWindowsExec ("calc"); //
    which should open up the calciulator, and should do for other os commands as well.
    Thanks

  • Calling a shell command from LabVIEW

    Platform:
    Labview 8.6 on Fedora 10.
    The VI is generating some data that I wish to convert to a form that a Windows user can work with (with CR/LF as the EOL). Is there a way to issue a shell command (specifically: $unix2dos <generated file name>) from within labview ? 
    Solved!
    Go to Solution.

    Hi,
    have you tried the "System Exec" function? According to context help it should work on UNIX too...
    Btw. you have asked a related question in an other thread. Wouldn't converting the string data in the VI itself work? Or making a special VI for that purpose and enable the conversion by a switch (like "Win compatible format?")?
    Message Edited by GerdW on 02-13-2010 09:38 AM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Running Copy command from Forms 6i

    HI!
    I want to run Copy command through Forms 6i i.e copy from scott/tiger@orcl insert test@msora(ename) using select to_char(ename) ename from emp;
    I can run DDL command through Forms_ddl functions in Forms 6i, But copy command is not working using Forms_ddl.
    thanks in advance.
    Edited by: Kami_Lily on Aug 2, 2009 10:04 PM

    Dear Kami Lily,
    Oracle Forms is able to execute SQL and PL/SQL command only. Additionally it supports Operating System command by HOST built-in.
    Though COPY is a SQL*Plus command, it is not possible to execute this command by HOST built-in.
    Instead, if you hardly want to execute COPY command oracle forms 6i, then you make a batch file in operating system and run that batch file from HOST built-in.
    Thanks.

  • Executing shell commands from Java.

    I want to execute shell commands in Java using the Runtime.exec( String ) method.
    The method works fine under Linux OS, but under Windows '98 the method didn't work at all!
    For example the following call: Runtime.exec( "dir" ) throws an exception showing that the command was not completed. If I replace dir with ls under Linux all is good. What is the problem with the Microsoft Windows '98 ? Is there any solution at my problem ?!
    thx in advance!

    hey JSarmis,
    You can help me... "ls" doesn't work for me on linux.. using Runtime.exec, some commands work, others don't... you may hold the key to what i need? How did u get "ls" to work?

  • How to call a HP-UX command or shell script from Forms 4.5

    Does anybody know how to call a unix command or shell script to get a files list of HP-UX server from Oracle Forms 4.5 on client side? I tried to use DBMS_PIPE package to get it done but I failed. Please let me have the solution if anybody knows how. Very urgent!

    I tried the host command before and it just let me shell to the DOS environment but not HP-UX environment as Forms was running on Windows platform. So, I could not run a unix command or a shell script. Is DBMS_PIPE the only way to get it done?

  • Run a shell script from FORM

    Hi,
    Is there a way that we can run a shell script on UNIX box from ORACLE FORMS 4.5 running on client PC (OS=windows on client,
    DB on unix).
    Thanks in advance for help

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Anton Weindl ([email protected]):
    You can either use rsh or rexec (both available on windows). You will have to edit the .rhosts in the home directory of the unix user the script will be run under:
    <Client-Hostname> <USER>
    <USER> must match the Windows-User exactly.
    You can then execute the Shell-Script with
    host('rsh <HOST> -l <USER> sh <SCRIPT>',NO_SCREEN)
    Hope that helps
    Anton Weindl
    <HR></BLOCKQUOTE>
    Thank You Anton Weindl,
    It seems like the thing I want to use instead of the dbms_pipe.
    I tried to use rsh and gives me the following message
    command: "rsh taurus -l nileshs test.sh"
    where taurus is hostname and
    guest is unix username
    I am logged on windows 2000 with this name.
    "taurus permission denied:"
    "rsh can't establish connection"
    Let me know if I am missing anything.
    Thanks.
    null

  • Execute OS command from form in 10g

    Hi,
    Is there a equivalent function/procedure in 10g forms for HOST command available in 6i?
    Migrated a form from 6i to 10g that contains HOST procedure. Now this is no longer working in 10g forms.
    Thanks

    Hello,
    I attached webutil.pll to the form and changed HOST to CLIENT_HOST.
    This is the actual code
    PROCEDURE CheckFTPDaemonStatus IS
        Str                VARCHAR2(100);
    BEGIN
      -- Check if FTP Daemon is up
    Str := 'ps -efx | grep TPFTP.jar | grep -v grep';
    Client_Host(Str);
    IF (NOT FORM_SUCCESS)
    THEN
            Message_Box(NULL,'FTP daemon is unavailable. Please start the FTP daemon.',0);
            EXIT_FORM(NO_COMMIT);
    END IF;
    END;This procedure is invoked when the form is being opened. Now the form itself is not coming up. Though ps -efx | grep TPFTP.jar | grep -v grep from UNIX command line shows this JAR is executing at OS level.
    I am running the form on HP-UX
    How do I check if CLIENT_HOST is successful or failure?
    Thanks

  • Invoking a UNIX shell command from Java stored procedure

    The program below is suppose do send an email using UNIX mailx program. It works correctly when I compile it in UNIX and invoke it from the command line by sending an email to the given address.
    I need this program to run as a stored procedure, however. I deploy it as such and try to invoke it. It prints the results correctly to the standard output. It does not send any emails, however. One other difference in execution is that when invoked from the command line, the program takes about a minute to return. When invoked as a stored procedure in PL/SQL program or SQL*Plus anonymous block, it returns immediately.
    Why would mailx invocation not work from a stored procedure? Are there other ways to invoke mailx from PL/SQL?
    Thank you.
    Michael
    import java.io.BufferedWriter;
    import java.io.IOException;
    import java.io.OutputStreamWriter;
    public class MailUtility
    public static void main(String[] args)
    System.out.println(mailx("Hey, there", "Hello", "oracle@solaris10ora", 1));
    * Sends a message using UNIX mailx command.
    * @param message message contents
    * @param subject message subject
    * @param addressee message addressee
    * @param display if greater than 0, display the command
    * @return OS process return code
    public static int mailx(String message, String subject,
    String addressee, int display)
    System.out.println("In mailx()");
    try
    String command =
    "echo \"" + message + "\" | mailx -r [email protected]" + " -s \"" + subject + "\" " + addressee;
    if (display > 0)
    System.out.println(command);
    try
    Process process = Runtime.getRuntime().exec("/bin/bash");
    BufferedWriter outCommand =
    new BufferedWriter(new OutputStreamWriter(process.getOutputStream()));
    outCommand.write(command, 0, command.length());
    outCommand.newLine();
    outCommand.write("exit", 0, 4);
    outCommand.newLine();
    outCommand.flush();
    process.waitFor();
    outCommand.close();
    return process.exitValue();
    catch (IOException e)
    e.printStackTrace();
    return -1;
    catch (Exception e)
    e.printStackTrace();
    return -1;

    try adding the full explicit path to "mailx" in the command string that gets sent to Runtime. i would guess that the shell that gets spawned might not have a proper environment and thus mailx might not be found.
    == sfisque

  • Call HOST command FROM FORMS 4.5 AND 6.0

    I have a problem that I found out about yesterday, and have no idea how to fixe it.
    I created a form to run on form 4.5.9.7 In this form i call up the host command, but it does not work properly, because by using the host oracle stops there until i close the application that i called with the host, it hangs there. But now it doesn't do it, once the host is executed, it continues the rest of the code that i have, which should not.
    On the same computer i created another form on forms 6.0.5.2 and call the host command again, and finally it worked perfect! I mean until the program called by host command is running forms does not continue, it hangs there.
    Could someone explains me that please, is there some patch I need on forms 4.5?
    null

    We converted forms from 4.5 to 6.0. Basically all you have to do is recompile the forms. but, the very first thing you have to do is recompile all the libraries. The forms will not work if you don't recompile the libraries first. So, open and compile the libraries in 6.0, then open and compile the forms in 6.0. They should then work fine. If they do not, try deleting and reattaching the libraries and compile again.
    Good luck.

  • Running shell command from Java, but from Windows Schedule Task?

    I have a simple java program that will start a dos based program. The java program works great when I run it, but when I run it from the Windows Task Scheduler, the dox box that should pop up, does not. It is running because I can see it in the task manager but I can not see the command window.
    Any ideas how to show the command window from a java application that is ran from Windows Task Scheduler?
    Example program below. Runs fine by itself, should get a dos popup that issues the directory command, run it from the scheduler and it does not show the dos box. You can however see it in the Processes as CMD.exe.
    import java.io.IOException;
    public class Test {
          * @param args
         public static void main(String[] args) {
              try {
                   Runtime.getRuntime().exec("cmd /k start dir");
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
    }Now the my real program is quite a bit more complicated. It actually goes out and checks the status of an Oracle Database, if all the tablespaces are online, then the middle tier application is allowed to start. The middle tier application is started by my java application, and is comes up with a dos console which shows status and users connected to the database.

    Jag,
    Actually, the question of whether it works for me seems to depend on the version of the OS (or Oracle). On RedHat Linux (Oracle 8.1.6) it didn't work at all, but on Solaris (Oracle 9.0.2) it did. Here's the output from that run:
    SQL> /
    output of the command run:
    init.ora
    initDBPart9i.DBPSun01.ora
    initdw.ora
    lkDBPART9I
    orapw
    orapwDBPart9i
    spfileDBPart9i.ora
    Done
    PL/SQL procedure successfully completed.
    But, I did need to change a line of your code to this:
    Process p = Runtime.getRuntime().exec("/usr/bin/ls");
    your original was:
    Process p = Runtime.getRuntime().exec("ls");
    You might consider, if possible, use of some of the Java File classes instead of ls, as this might make things more predictable for you. There were some examples in oramag.com a few months ago, but they were pretty simple (you might not need them).
    Hope this helps,
    -Dan
    http://www.compuware.com/products/devpartner/db/oracle_debug.htm
    Debug PL/SQL and Java in the Oracle Database

  • Issues with running UNIX shell command from Java

    Here is my java class file:
    create or replace and compile java source named host as
    import java.lang.* ;
    public class Host
       public static void cmdTest()
            String cmd = "ps -ef | grep orcl" ;
            int rc = 0 ;
            int = runCmd(cmd) ;
       public static int runCmd(String str )
           Runtime rt = Runtime.getRuntime() ;
           int     rc = -1 ;
          try
                Process p = rt.exec(str) ;
                int bufSize = 4096 ;
                BufferedInputStream bis =
                    new BufferedInputStream(p.getInputStream(), bufSize) ;
                int len ;
                byte buffer[] = new byte[bufSize] ;
                // Log what the program spit out
                while ((len = bis.read(buffer, 0, bufSize)) != -1)
                    rc = p.waitFor() ;
            catch (Exception e)
                e.printStackTrace();
                rc = -1 ;
            finally
                return rc ;
    show errorsI can call runCmd directly from SQLPlus using an Oracle stored procedure and it runs like expected. I can see the returned output using dbms_java.set_output(1000000).
    But when I call cmdTest from SQLPlus using an Oracle stored procecdure it just hangs forever and I have to kill the session.
    Is there something I am missing in the cmdTest method?

    Jimmy,
    If you haven't already seen it, I think the following article may be of help:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
    Also a "finally" block should not contain a "return" statement:
    http://weblogs.java.net/blog/staufferjames/archive/2007/06/_dont_return_in.html
    Good Luck,
    Avi.

Maybe you are looking for

  • Developer 6i with patch 18 and oracle 11g connection issue

    hi , I installed Oracle database 11g on server , when login to my application and open any form or report ,get oracle connection user and password what should i do ? please help me

  • Linking a class to a symbol

    I have a simple progress bar symbol (ProgBar) in the library of main.fla. If I don't define a class and allow Flash to assign a placeholder class of ProgBar, then the symbol displays ok using progBar = new ProgBar(); addChild(progBar); If I define a

  • HT4906 how can I export from macbookpro my pictures to my iPhone?

    my girlfriend is always laughing at me, she is having a sony notebook and can work easyly with bluetooth,manage pictures fast, while I am standing here and a kind of helpless ( she is kidding, that this MAC is just a name and expensive ,) I told her

  • Speed Grapher incomplete

    Hi! Speed Grapher is incomplete. Only the first 20 episodes out of 24 are listed. But the price is for all 24. The last 4 episodes need to be posted there ASAP and the people that purchased it need to be told to come back and retrieve the last 4 epis

  • Equipment Master Location Tab End Customer data

    Dear All, I have a requirment to fetch the name and address of the end customer maintained in the Equipment and Serial number master data. Kindly help me to fetch the relevent customer detail with respect to Equipement master. Regards, SaravanaaS