Shell command execution from HTMLDB

I created a Java procedure for host calls on Unix environment, it seems to be working under sqlplus, the commands like "rc('/bin/mkdir /tmp/linkin);" works fine if used from within sqlplus but when executed from within html_db no directory is created. How can I do it in html_db?, though it says the commands are successful.
I execute these commands like
begin
rc('/bin/ps -ef');
end;
I would apreciate any inputs in this regard. If anyone can think of other solution to this problem, please let me know as i want to submit a shell job from htmldb.
Anand

I made a java procedure to do this but, the command is being executed as it says but am not able to see the output.
Now i wonder why am checking if it has got somethng to do with access rights from enterprise manager.
Still trying

Similar Messages

  • Java interactive Shell command Execution

    Hello,
    I wish to execute a shell command with password from a java program. I want to issue the first command "serctl add 2000 password email" and then when prompted for a MySQL password, enter it.
    Below is my current code. I think it is going into an infinite loop. When I comment out the "while ((s = in.readLine()) != null){" portion of the code, I dont get an infinite loop but then i dont know how to enter the password.
    Can someone please please help me as im really stuck on this?
    BR,
    Aisling.
    String[] command = { "serctl", "add", 2000, password, email};
    Runtime runtime = Runtime.getRuntime();
       Process process = null;
       response.setContentType(CONTENT_TYPE);
       PrintWriter out = response.getWriter();
       String s = null;
       try {
         process = runtime.exec(command);
         System.out.println(process);
         BufferedReader in =
         new BufferedReader(new InputStreamReader(process.getInputStream()));
         BufferedReader error = new BufferedReader(new InputStreamReader(process.getErrorStream()));
         OutputStream stdout = process.getOutputStream();
         String pwd ="password";
      /*   while((s=in.readLine())!=null)
           s = in.readLine();
           System.out.println(s);
           stdout.write(pwd.getBytes());
           stdout.flush();
         System.out.println("Here is the standard error of the command(if any):\n");
         while ((s = error.readLine()) != null){
           System.out.println(s);
         stdout.close();
         in.close();
         error.close();

    Thats great and I think that should have worked...However its still hanging and evidently going into some kind of loop....very strange.
    If I execute the command in a shell its as follows:
    localhost: ~# serctl add 2000 password email
    MySql password: password
    My new code is below:
    String[] command = { "serctl", "add", username, password, email};
       Runtime runtime = Runtime.getRuntime();
       Process process = null;
       response.setContentType(CONTENT_TYPE);
       PrintWriter out = response.getWriter();
       String s = null;
       try {
         process = runtime.exec(command);
         System.out.println(process);
         BufferedReader in =
         new BufferedReader(new InputStreamReader(process.getInputStream()));
         BufferedReader error = new BufferedReader(new InputStreamReader(process.getErrorStream()));
         OutputStream stdout = process.getOutputStream();
         String pwd ="password";
         while((s=in.readLine())!=null)
           //s = in.readLine();
           System.out.println(s);
           if (s.equals("MySql password:")) {
             stdout.write(pwd.getBytes());
             stdout.flush();
             break;
         System.out.println("Here is the standard error of the command(if any):\n");
         while ((s = error.readLine()) != null){
           System.out.println(s);
         stdout.close();
         in.close();
         error.close();Any more ideas?
    Many thanks for help so far,
    Aisling.

  • Shell script execution from stored procedure

    I am working on a project thallt requires a shell script be executed upon the execution of a stored procedure with Oracle 10g. I have researched the matter, but there does not seem to be much out there on how to execute lines of UNIX commands by use of a stored procedure. If anybody has ever gotten this to work, any information would be appreciated. If the task is impossible, let me know, I just could not confirm that it was not something that could be done.

    A combination of things can help you out here - none of which are easy or particularily secure.
    1) From plain PL/SQL, you can call 'external procedures'. That is basically a DLL or .so that the listener can load on demand, and that external procedure (EXTPROC) can run whatever you need from the C program. C can, in turn, call a shell.
    This is fairly well documented, but be aware that 1/2 of the info is in the PL/SQL docco and the other half in the Networking docco.
    A fair bit of info is available in metalink as well - if you have access, simply search on extproc.
    2) You can call a Java stored procedure which in turn has hooks to the outside world. That will probably require a PL/SQL to Java wrapper to make it available in your environment. Oracle has been using this one successfully for a while.
    3) Write the script using UTL_FILE and have a daemon look for, and execute, the script.
    4) Since you are using 10g, use the new job scheduler. It has excellent capability to interact with the OS, and it is available as a PL/SQL package (DBMS_SCHEDULER). I find the interface a bit heavy, but that could be wrapped by a library tailored to your specific needs.
    Let us know what you decide to do in the end (and why) - it is an interesting topic.

  • 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

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

  • Running Shell Commands (not Executable) in Unix from Java

    What are my options to run shell commands from Java?
    My goal is to change my existing shell environment variables to some new ones provided by .anotherProfile.
    Using an executable from Java is not an option because it does not work i.e. ( exec(". /home/.profile") ) brings up errors.
    Someone has suggested that I start a child shell with that profile and work from there, but I'm unfamiliar with that sort of syntax and programming in general.
    Any good help equals duke dollars :)

    Well there are some possibilities. In the original thread you mentioned that you wanted the shell script to be executed to change some enviroment parameters of the shell the JVM is executing in.
    If so, and you are able to rewrite the profile so you can parse it manually. Then you can change some environment setting by writing the JNI wrappers for the getenv and setenv system calls. (Check your man pages)
    That will change the environment. I am just wondering what good it will do for you? What's use of sourcing the profile in a JVM?

  • 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

  • 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

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

  • 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

  • Error with dbms_scheduler and shell script execution

    Hi,guys.
    I have an issue with a dbms_scheduler and a shell script execution. So, the shell script as it self works fine, when i'm executing ./test.sh all process is running, but when i'm executing the script from dbms_scheduler it just simply doesn't work. Actually it works, but some of executable information in sh doesn't work, seems it just jump over of the part of the script. Sendmail part is running, maybe there is problem with rman script as it self?
    DB version: 10g
    And my scripts:
    Shell scripts (permisons 755):
    #!/bin/ksh
    export PATH=/home/oracle/product/asm_home/bin:/home/oracle/product/db_home/bin:/usr/bin:/etc:/usr/sbin:/usr/ucb:/home/oracle/bin:/usr/bin/X11:/sbin:.
    export ORACLE_BASE=/home/oracle/product
    export ORACLE_SID=zabbix
    export ORACLE_HOME=/home/oracle/product/db_home
    ${ORACLE_HOME}/bin/rman<<EOF
    connect target /
    run {backup recovery area delete all input;}
    EOF
    {       echo "From:[email protected]"
            echo "To: [email protected]"
            echo "Subject: Recovery area"
            echo 'Content-Type: text/html'
            echo
            echo '<html><body><table border="1" cellspacing="1">'
            echo '<tr><td><b>Process</b></td><td><b>Statuss</b></td></tr>'
            echo "<tr><td>RMAN</td><td><b>Works</b></td></tr>"
            echo "</table></body></html>"
    } | sendmail -tIn the first part i'm exporting all of the important stuff for oracle, then I call RMAN with specific atributes. And then there is just simply sendmail functionality inside script to represent if script works (for now).
    And below pl/sql script:
    begin
      DBMS_SCHEDULER.CREATE_JOB
      job_name => 'FLASH_RECOVERY',
      job_type => 'EXECUTABLE',
      job_action => '/home/oracle/backup/test.sh',
      start_date => sysdate,
      job_class => 'DEFAULT_JOB_CLASS',
      enabled => TRUE,
      auto_drop => FALSE,
      comments => 'FLASH RECOVERY USAGE AREA backup and delete'
      END;
      /And this job execution:
           begin
               DBMS_SCHEDULER.run_job (job_name =>'FLASH_RECOVERY',use_current_session => TRUE);
           end;What can be wrong? For me, I think it's something with permisions.
    I hope you got my idea and could help me.
    Tom
    Edited by: safazaurs on 2013.18.2 22:16

    There is no error, i just receive all the time e-mail, seems it jumps over rman. I tried almost everything and still couldn't get result as i want. And, if i'm running script from command line - it works. Rman calls, and starts to recover archivelogs.

  • Help 'Exiting' after Automator Shell Script Execution

    Hello,
    I've recently installed and got running GCalDaemon (http://gcaldaemon.sourceforge.net/) which allows me to Synch Rainlendar <-> Google Calendar through iCal (You can also synch iCal <-> Google Calendar). I needed to start up a shell script/applescript after each startup/login in order for GCalDaemon to start the synching process each time and continue to do so at the timed intervals. I would do so by the following terminal code:
    cd /usr/local/sbin/GCALDaemon/bin
    ./standalone-start.sh
    I then tried automating this process and came across shell script execution through Automator. I did so and created a .app with the above mentioned code. This works and it starts up the necessary .sh file I need and the snyching works under StartUp. My concern is however, how do I exit terminal once the code has executed the necessary file? All I have in my .app is the above mentioned code for now. I just need it to exit terminal because on startup or after starting the program, I get this issue (See Attachment)
    This continues to run, so my guess is that I need to add code to exit terminal and allow the .app to close itself properly after doing so.
    Please guide me in the right direction.
    Picture Belows shows what happens when I run the Automator App. It continues to run until I quit out of the app manually (TheGCal programs works fine though). I feel I need to have app quit Terminal or fully end the process and quit out on it's own.
    Thanks
    <table style="width:auto;"><tr><td></td></tr><tr><td style="font-family:arial,sans-serif; font-size:11px; text-align:right">From GCalDaemon</td></tr></table>

    i redirected the command output to /dev/null which is unix equivalent of a black hole and I also redirected error output to standard output in case the script produces any errors.
    also & at the end tells it to continue without waiting for the script to finish.
    Message was edited by: V.K.

  • Deploy and runnig app on ipad using shell command or others

    Hello,
    How to deploy and run an app from Mac on an iPad using a shell command or others like a program in c or objective-c.
    Thank you in advance
    Mickael

    These libraries are developed by us for iOS and automatically built every day.
    After each building we must launch this application (iOS) tests that implements our libraries.
    we would like to automate the deployment of this app and its execution on an iPAD connected via USB cable to the Mac of production.

Maybe you are looking for