Running OS command using DBMS_PIPE

Hi,
I have reproduce the exemple in the documentation DBMS_PIPE - Example 3: Execute System Commands using the proc daemon.pc. It works, the commands are getting executed, but I have no control over them. What I need is for the calling PL/SQL function to wait for the OS command to finnish before continuing with the execution the PL/SQL function.
Any hint would be appreciated. Thanks.

odie_63 wrote:
Justin Cave wrote:
The normal way to approach that sort of requirement would be to use a Java stored procedure.Or a DBMS_SCHEDULER external program with "use_current_session" set to true.
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sched.htm#i1013568
On 10g+ I'd definitely give this a go.

Similar Messages

  • I want run some command using java

    hi all,
    i want run command using java code.
    from cell prompt when i run this command 'mysqldump test > /home/DBNAME.sql'
    it will create DBNAME.sql file.
    but i want to run this command using java code
    i tried the following code but it did not work.
    is any other way is their?
    try {
                   Runtime.getRuntime().exec("setxkbmap nudi");
              } catch(IOException ioe) {
                   ioe.printStackTrace();
    thanks in advance
    daya

    hello,
    thanks for replay
    i am sorry the above code should be like this.(the above code is working fine)
    public class ExportTest{
         public ExportTest(){
              try {
                   Runtime.getRuntime().exec("mysqldump test > '/root/DBNAME.sql'");
              } catch(IOException ioe) {
                   ioe.printStackTrace();
              }catch(Exception e){
                   e.printStackTrace();
         public static void main(String args[]){
              new ExportTest();
    }when run above class, it not creating DBNAME.sql file.
    when run in command prompt it creating DBNAME.sql
    ($ mysqldump test > /root/DBNAME.sql)
    but i want to run this command from java code, that's way tried to do using above
    code, but it won't create DBNAME.sql
    is it wrong what i am doing? or any other way?
    thanks inadvace
    daya

  • Run shell commands using java program

    Hi guys,
    I am trying to run shell commands like cd /something and ./command with arguments as follows, but getting an exception that ./command not found.Instead of changing directory using "cd" command I am passing directory as an argument in rt,exec().
    String []cmd={"./command","arg1", "arg2", "arg3"};
    File file= new File("/path");
    try{
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec(cmd,null,file);
    proc.waitFor();
    System.out.println(proc.exitValue())
    BufferedReader buf = new BufferedReader(new InputStreamReader(proc.getInputStream()));
    catch(Exception e)
    {e.printStackTrace();
    So can anyone please tell me what is wrong with this approach? or is there any better way to do this?
    Thanks,
    Hardik

    warnerja wrote:
    What gives you the idea that the process to execute is called "./command"? If this is in Windows, it is "cmd.exe" for example.It does not have to be cmd.exe in Windows. Any executable or .bat file can be executed as long as one either specifies the full path or the executable is in a directory that is in the PATH.
    On *nix the file has to have the executable bit set and one either specifies the full path or the executable must be in a directory that is in the PATH . If the executable is a script then if there is a hash-bang (#!) at the start of the first line then the rest of the line is taken as the interpreter  to use. For example #!/bin/bash or #!/usr/bin/perl .
    One both window and *nix one can exec() an interpreter directly and then pass the commands into the process stdin. The advantage of doing this is that one can change the environment in one line and it  remains in effect for subsequent line. A simple example of this for bash on Linux is
    import java.io.OutputStreamWriter;
    import java.io.Writer;
    public class ExecInputThroughStdin
        public static void main(String args[]) throws Exception
            final Process process = Runtime.getRuntime().exec("bash");
            new Thread(new PipeInputStreamToOutputStreamRunnable(process.getErrorStream(), System.err)).start();
            new Thread(new PipeInputStreamToOutputStreamRunnable(process.getInputStream(), System.out)).start();
            final Writer stdin = new OutputStreamWriter(process.getOutputStream());
            stdin.write("xemacs&\n");
            stdin.write("cd ~/work\n");
            stdin.write("dir\n");
            stdin.write("ls\n");
            stdin.write("gobbldygook\n"); // Forces output to stderr
            stdin.write("echo $PATH\n");
            stdin.write("pwd\n");
            stdin.write("df -k\n");
            stdin.write("ifconfig\n");
            stdin.write("echo $CWD\n");
            stdin.write("dir\n");
            stdin.write("cd ~/work/jlib\n");
            stdin.write("dir\n");
            stdin.write("cat /etc/bash.bashrc\n");
            stdin.close();
            final int exitVal = process.waitFor();
            System.out.println("Exit value: " + exitVal);
    }One can use the same approach with Windows using cmd.exe but then one must be aware of the syntactic differences between commands running in .bat file and command run from the command line. Reading 'help cmd' s essential here.
    The class PipeInputStreamToOutputStreamRunnable in the above example just copies an InputStream to an OutputStream and I use
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    public class PipeInputStreamToOutputStreamRunnable implements Runnable
        public PipeInputStreamToOutputStreamRunnable(InputStream is, OutputStream os)
            is_ = is;
            os_ = os;
        public void run()
            try
                final byte[] buffer = new byte[1024];
                for (int count = 0; (count = is_.read(buffer)) >= 0;)
                    os_.write(buffer, 0, count);
            } catch (IOException e)
                e.printStackTrace();
        private final InputStream is_;
        private final OutputStream os_;
    }

  • Running unix command using java shows error

    Hi All,
    I am trying to run UNIX move command using Java exec method but its throwing error, unable to rename. Here below is the code i am trying to run to move all files from one directory to another directory. source and destination directory exists.
    public class Demo
        public static void main(String args[])
            try
                Runtime rt = Runtime.getRuntime();
                Process proc = rt.exec("mv /home/demo1/* /home/demo2");
                int exitVal = proc.waitFor();
                System.out.println("Process exitValue: " + exitVal);
            } catch (Throwable t)
                t.printStackTrace();
    }if i give "mv /home/demo1 /home/demo2" in exec method, its working, with * character its giving problem.
    Please help me in resolving the problem.
    Thank you

    Characters like *, >, &, |, etc. are interpreted by the command shell--that is by the bash, zsh, etc. programs. When you execute a command with ProcessBuilder or Runtime.exec, you're not going through one of those shells, so their interpretation of those characters is not available.
    In your code, the character * is being delivered directly to the mv command (which doesn't think * is anything special), as opposed to being turned into a list of files and directories as it would be when it's interpreted by the shell. The mv command doesn't know anything about the * character being special.
    If you want to have those shell interpretations, you need to execute the command through a shell. One example is like so, but a) you'll want to read up on the methods in exec() that take arrays of String, and b) you'll want to read up on ProcessBuilder, and c) you'll need to check your shell's man pages to see the exact syntax and arguments.
    runtime.exec("/bin/bash -c 'mv x/* y'");

  • Running 5 commands using array elements and waiting between?

    Hi All,
    Trying to learn PS so please be patient with me ;)
    System: PSv3 on Win2012 server running WSUS role
    I am wanting to execute 5 commands using a 'foreach' loop but wait until one finishes before moving onto the next. Can you please check out what I have and provide some suggestions of improvement? or scrap it completely if it's rubbish :(
    Current code:
    #### SCRIPT START ####
    #Create and define array and elements
    $Array1 = @(" -CleanupObsoleteComputers"," -DeclineSupersededUpdates -DeclineExpiredUpdates"," -CleanupObsoleteUpdates"," -CleanupUnneededContentFiles"," -CompressUpdates")
    #Run the cleanup command against each element
    foreach ($element in $Array1) {
    Get-WsusServer | Invoke-WsusServerCleanup $element -Whatif
    #### SCRIPT END ####
    I am assuming that I need to use @ to explicitly define elements since my second element contains two commands with a space between?
    The cleanup command doesn't accept '-Wait' so I'm not sure how to implement a pause without just telling it to pause for x time; not really a viable solution for this as the command can sometime take quite a while. They are pretty quick now that I do
    this all the time but just want it to be future proof and fool proof so it doesn't get timeouts as reported by others.
    I have found lots of code on the net for doing this remotely and calling the .NET assemblies which is much more convoluted. I however want to run this on the server directly as a scheduled task and I want each statement to run successively so it
    doesn't max out CPU and memory, as can be the case when a single string running all of the cleanup options is passed.
    Cheers.

    Thank you all for your very helpful suggestions, I have now developed two ways of doing this. My original updated (thanks for pointing me in the right direction Fred) and Boe's tweaked for my application (blew my mind when I first read that API code
    Boe). I like the smaller log file mine creates which doesn't really matter because I am only keeping the last run data before trashing it anyway. I have also removed the verbose as I will be running it on a schedule when nobody will be accessing it anyway,
    but handy to know the verbose commands ;)
    Next question: How do I time these to see which way is more efficient?
    My Code:
    $Array1 = @("-CleanupObsoleteComputers","-DeclineSupersededUpdates","-DeclineExpiredUpdates","-CleanupObsoleteUpdates","-CleanupUnneededContentFiles","-CompressUpdates")
    $Wsus = Get-WsusServer
    [String]$Logfile = 'C:\Program Files\Update Services\LogFiles\ArrayWSUSCleanup.log'
    [String]$Logfileold = 'C:\Program Files\Update Services\LogFiles\ArrayWSUSCleanup.old'
    If (Test-Path $Logfileold){
    Remove-Item $Logfileold
    If (Test-Path $Logfile){
    Rename-Item $Logfile $Logfileold
    foreach ($Element in $Array1)
    Get-Date | Out-File -FilePath $LogFile -Append -width 50
    Write-Output "Performing: $($Element)" | Out-File -FilePath $LogFile -Append -width 100
    . Invoke-Expression "`$Wsus | Invoke-WsusServerCleanup $element" | Out-File -FilePath $LogFile -Append -width 100
    Logfile Output {added 1 to show what it looks like when items are actions}:
    Wednesday, 27 August 2014 2:14:01 PM
    Obsolete Computers Deleted:1
    Wednesday, 27 August 2014 2:14:03 PM
    Obsolete Updates Deleted:1
    Wednesday, 27 August 2014 2:14:05 PM
    Expired Updates Declined:1
    Wednesday, 27 August 2014 2:14:07 PM
    Obsolete Updates Deleted:1
    Wednesday, 27 August 2014 2:14:09 PM
    Diskspace Freed:1
    Wednesday, 27 August 2014 2:14:13 PM
    Updates Compressed:1
    Boe's Updated Code:
    [String]$WSUSServer = 'PutWSUSServerNameHere'
    [Int32]$Port = 8530 #Modify to the port your WSUS connects on
    [String]$Logfile = 'C:\Program Files\Update Services\LogFiles\APIWSUSCleanup.log'
    [String]$Logfileold = 'C:\Program Files\Update Services\LogFiles\APIWSUSCleanup.old'
    If (Test-Path $Logfileold){
    Remove-Item $Logfileold
    If (Test-Path $Logfile){
    Rename-Item $Logfile $Logfileold
    [Void][reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration")
    $Wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($WSUSServer,$False,$Port)
    $CleanupMgr = $Wsus.GetCleanupManager()
    $CleanupScope = New-Object Microsoft.UpdateServices.Administration.CleanupScope
    $Properties = ("CleanupObsoleteComputers","DeclineSupersededUpdates","DeclineExpiredUpdates","CleanupObsoleteUpdates","CleanupUnneededContentFiles","CompressUpdates")
    For ($i=0;$i -lt $Properties.Count;$i++) {
    $CleanupScope.($Properties[$i])=$True
    0..($Properties.Count-1) | Where {
    $_ -ne $i
    } | ForEach {
    $CleanupScope.($Properties[$_]) = $False
    Get-Date | Out-File -FilePath $LogFile -Append -width 50
    Write-Output "Performing: $($Properties[$i])" | Out-File -FilePath $LogFile -Append -width 100
    $CleanupMgr.PerformCleanup($CleanupScope) | Out-File -FilePath $LogFile -Append -width 200
    Logfile Output {added 1 to show what it looks like when items are actions}:
    Wednesday, 27 August 2014 2:32:30 PM
    Performing: CleanupObsoleteComputers
    SupersededUpdatesDeclined : 0
    ExpiredUpdatesDeclined    : 0
    ObsoleteUpdatesDeleted    : 0
    UpdatesCompressed         : 0
    ObsoleteComputersDeleted  : 1
    DiskSpaceFreed            : 0
    Wednesday, 27 August 2014 2:32:32 PM
    Performing: DeclineSupersededUpdates
    SupersededUpdatesDeclined : 1
    ExpiredUpdatesDeclined    : 0
    ObsoleteUpdatesDeleted    : 0
    UpdatesCompressed         : 0
    ObsoleteComputersDeleted  : 0
    DiskSpaceFreed            : 0
    Wednesday, 27 August 2014 2:32:34 PM
    Performing: DeclineExpiredUpdates
    SupersededUpdatesDeclined : 0
    ExpiredUpdatesDeclined    : 1
    ObsoleteUpdatesDeleted    : 0
    UpdatesCompressed         : 0
    ObsoleteComputersDeleted  : 0
    DiskSpaceFreed            : 0
    Wednesday, 27 August 2014 2:32:36 PM
    Performing: CleanupObsoleteUpdates
    SupersededUpdatesDeclined : 0
    ExpiredUpdatesDeclined    : 0
    ObsoleteUpdatesDeleted    : 1
    UpdatesCompressed         : 0
    ObsoleteComputersDeleted  : 0
    DiskSpaceFreed            : 0
    Wednesday, 27 August 2014 2:32:38 PM
    Performing: CleanupUnneededContentFiles
    SupersededUpdatesDeclined : 0
    ExpiredUpdatesDeclined    : 0
    ObsoleteUpdatesDeleted    : 0
    UpdatesCompressed         : 0
    ObsoleteComputersDeleted  : 0
    DiskSpaceFreed            : 1
    Wednesday, 27 August 2014 2:32:43 PM
    Performing: CompressUpdates
    SupersededUpdatesDeclined : 0
    ExpiredUpdatesDeclined    : 0
    ObsoleteUpdatesDeleted    : 0
    UpdatesCompressed         : 1
    ObsoleteComputersDeleted  : 0
    DiskSpaceFreed            : 0

  • Running Dos Command using Java

    How do i run a particular Dos command using a simple java class?

    Process process = Runtime.getRuntime().exec( ... );
    Search the forum. There are plenty of examples.

  • Running System commands using Runtime.exec()

    I'm trying to run an example from "The Java Programming Language" book by Arnold, Gosling and Holmes. I'm trying to run a system level command and get the results. The code looks like:
    public static String[] runCommand(String cmd) {
    String[] outputData= null;
    String[] cmdArray = {"/usr/bin/ls", "-l", "/tmp"};
    try {
    Process child = Runtime.getRuntime().exec(cmdArray);
    InputStream in = child.getInputStream();
    InputStreamReader reader = new InputStreamReader(output);
    BufferedReader = new BufferedReader(reader);
    // read the commands output
    int counter = 0;
    String line;
    while ((line = input.readLine()) != null)
    outputData[counter++]= line;
    if (child.waitFor() != 0){  // error when it's not 0       
    System.out.println("Couldn't run the command.");
    System.out.println("It produced the following error message : " + child.exitValue());
    outputData = null;
    } catch (Exception e){
    System.out.println("It got here!");
    System.out.println("It produced the following error message : " + e.getMessage());
    outputData = null;
    return outputData;
    It gets to the while line, trys to run the input.readLine() and kicks out the exception that looks like:
    It got here!
    It produced the following error message : null
    I know it gets to the input.readLine() because I had a whole lot more try blocks in there, but for simplicity left it out (so it look like the code in the book, which I tried originally). When I run the same command from the command line (on our Sun Solaris 2.8 system) I get results back. I'm not sure what I'm doing wrong. Any help would be greatly appreciated. Thanks.

    Hi, duffymo, hope you can help me. Consider this servlet code:
    String theCommand = "csh /export/home/gls03/sasstuff/runsas.csh /export/home/g
    ls03/sasstuff/gary2.sas";
    //Create a parent Process for the sas program subprocess:
    Process p = rt.exec(theCommand);
    System.out.println("after call to rt.exec(theCommand)");
    Here is the runsas.csh script:
    #!/bin/csh
    setenv LD_LIBRARY_PATH /opt/sybase/lib:/usr/lib:/usr/openwin/lib:/opt/SUNWspro/S
    C2.0.1
    setenv SASROOT /usr/local/CDC/SAS_8.2
    setenv XKEYSYMDB /usr/local/CDC/SAS_8.2/X11/resource_files/XKeysymDB
    $SASROOT/sas -sasuser /hpnpages/cgi-bin/applinks/hospcap/tmp $1
    The execution never gets to the println statment, here is the error:
    class java.io.IOException Exception. Message: CreateProcess: csh /export/home/g
    ls03/sasstuff/runsas.csh /export/home/gls03/sasstuff/gary2.sas error=2
    java.io.IOException: CreateProcess: csh /export/home/gls03/sasstuff/runsas.csh /
    export/home/gls03/sasstuff/gary2.sas error=2
    at java.lang.Win32Process.create(Native Method)
    at java.lang.Win32Process.<init>(Win32Process.java:66)
    at java.lang.Runtime.execInternal(Native Method)
    at java.lang.Runtime.exec(Runtime.java:551)
    at java.lang.Runtime.exec(Runtime.java:477)
    at java.lang.Runtime.exec(Runtime.java:443)
    at sasRunnerNew.doPost(sasRunnerNew.java:103)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
    pl.java:262)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:21)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.ja
    va:27)
    at us.ny.state.health.hin.hinutil.HinFilter.doFilter(HinFilter.java:124)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.ja
    va:27)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
    rvletContext.java:2643)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
    pl.java:2359)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    The command runs fine in unix.
    I've also tried using these as arguments to exec:
    String theCommand = "/bin/csh /export/home/gls03/sasstuff/runsas.csh /export/home/gls03/sasstuff/gary2.sas";
    String[] theCommand = {"csh", "/export/home/gls03/sasstuff/runsas.csh", "/export/home/gls03/sasstuff/gary2.sas"};
    These generate the same error. I'm thinking this is a sas-specific problem.
    Thanks for any help. Gary

  • To run a command using java code

    hi all,
    There is a command
    "java -jar selenium-server.jar -interactive"
    which i am running through command prompt after going to D:\MyFolder\Examples .
    i want to execute this command using java code .please help

    subratjyetki wrote:
    please answer in detail or if posible can u give the code for thisThe detail is given in the reference. Why don't you read it?
    I could give you the code but it will cost you ?100 per hour.

  • Running System Commands using Java

    HI,
    I am developing an application using java which requires some system commands to be run.For example i have to write a java function which can program the windows scheduler to run a particular executable at some time & another one to initiate an ftp.I however do not know how to execute the corresponding commands from java.Is there any way or some specific api(similar to the system command in c) that i can use to perform these operations.I am using j2sdk 1.4.0_01 on a win 98 machine to develop the application.

    See [url http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html]java.lang.Runtime

  • Deploy wsp through Power Shell- start stop SP admin service and run execadmsvcjobs command using power shell

    Hi,
     Can anyone pls point me any link/ src code  for  deplyoing wsp using power shell. I know I can deploy it through Add-spsolution and install-spsolution, the issue is that, it will give   "status - stuck in deploying scheduled..."
    and i need to restart the sharepoint services - services.msc --> SP administration and timer services - and then i need to run the exceadmsvcjobs command to deploy / update the wsp  successfully in solution store.
    i mean, whats the power shell equivalent of these tasks. or anyone has already scripted these.
    if i elaborate little bit, would like to know how to automatically Retract, Remove, Add and Deploy SharePoint 2010 WSP Solution Files with PowerShell

    ok, i have found  the same :
     here its : hope this will help someone.
    function wait4timer($solutionName)
    $solutionName ="TestingWSP.wsp"
    $solution = Get-SPSolution | where-object {$_.Name -eq $solutionName}
    if ($solution -ne $null)
    Write-Host "Waiting to finish soultion timer job" -ForegroundColor Green
    while ($solution.JobExists -eq $true )
    Write-Host "Please wait...Either a Retraction/Deployment is happening" -ForegroundColor DarkYellow
    sleep 5
    Write-Host "Finished the solution timer job" -ForegroundColor Green
    try
    # Get the WebApplicationURL
    $MyWebApplicationUrl = "http://srvr:21778/";
    # Get the Solution Name
    $MywspName = "TestingWSP.wsp"
    # Get the Path of the Solution
    $MywspFullPath = "D:\myWorkspace\TestingWSP.wsp"
    # Try to get the Installed Solutions on the Farm.
    $MyInstalledSolution = Get-SPSolution | Where-Object Name -eq $MywspName
    # Verify whether the Solution is installed on the Target Web Application
    if($MyInstalledSolution -ne $null)
    if($MyInstalledSolution.DeployedWebApplications.Count -gt 0)
    wait4timer($MywspName)
    # Solution is installed in atleast one WebApplication. Hence, uninstall from all the web applications.
    # We need to unInstall from all the WebApplicaiton. If not, it will throw error while Removing the solution
    Uninstall-SPSolution $MywspName -AllWebApplications:$true -confirm:$false
    # Wait till the Timer jobs to Complete
    wait4timer($MywspName)
    Write-Host "Remove the Solution from the Farm" -ForegroundColor Green
    # Remove the Solution from the Farm
    Remove-SPSolution $MywspName -Confirm:$false
    sleep 5
    else
    wait4timer($MywspName)
    # Solution not deployed on any of the Web Application. Go ahead and Remove the Solution from the Farm
    Remove-SPSolution $MywspName -Confirm:$false
    sleep 3
    wait4timer($MywspName)
    # Add Solution to the Farm
    Add-SPSolution -LiteralPath "$MywspFullPath"
    # Install Solution to the WebApplication
    #Install-SPSolution -Identity <SolutionName> -WebApplication <URLName> [-GACDeployment] [-CASPolicies]
    install-spsolution -Identity $MywspName -WebApplication $MyWebApplicationUrl -GACDeployment #-FullTrustBinDeployment:$true -GACDeployment:$false -Force:$true
    # Let the Timer Jobs get finishes
    wait4timer($MywspName)
    Write-Host "Successfully Deployed to the WebApplication" -ForegroundColor Green
    catch
    Write-Host "Exception Occuerd on DeployWSP : " $Error[0].Exception.Message -ForegroundColor Red
    ref :
    http://www.sharepointpals.com/post/How-to-Deploy-a-SharePoint-2013-Solution-(WSP)-in-the-Farm-using-PowerShell

  • Problem in running system commands using Runtime()

    hi,
    i am trying to run the "dir" command in windows OS using Runtime(). But while
    executing the program i am getting
    java.io.IOException: CreateProcess: dir error=2 error. But if i replace the "dir" command by "notepad" command its working fine. below is the source code.
    class testing
    public static void main(String args[])
         try{
    Runtime rt=Runtime.getRuntime();
    Process p=rt.exec("dir"); //Generating Errors
    //Process p=rt.exec("notepad"); //Working Fine
         }catch(Exception e){System.out.println(e);}
    }plzz help me out.
    thanx

    thats fine its working. i made two changes. First i used an array to send the
    arguments. if we directly use "cmd.exe /c dir" then its converting "/C" to "\C" thus
    producing the error. so i used
    Runtime rt=Runtime.getRuntime();
    String args1[]={"cmd.exe","/C","dir"};
    Process p=rt.exec(args1);But then i got no error no output. From other forums i came to know about capturing the data using input streams and i included the following code.
    BufferedReader Resultset = new BufferedReader
         (new InputStreamReader(p.getInputStream()));
    String line;
    while ((line = Resultset.readLine()) != null)
         {          System.out.println(line);          }Now its working fine. Thanx for ur help.

  • Running OS command using OEM 11gR1

    Hi,
    I have installed OEM 11gR1 on linux 64bit machine and have applied all recommended patches on top of it. Everything worked out fine till i got to the part of configuring my database alert.
    Database Instance: UAT > All Metrics > Tablespace Space Used (%) > Tablespace Name APPS_UNDOTS1 >
    Jun 14, 2012 1:31:38 PM User Action SYSTEM SYSMAN initiated a manual reevaluation of the alert.
    Jun 8, 2012 1:13:36 PM Corrective Action <SYSTEM> Execution created for Corrective Action INITIATE_SMS.
    Jun 8, 2012 1:13:36 PM Corrective Action <SYSTEM> Another Corrective Action INI not run since there is an existing running execution of CA INITIATE_SMS.
    Jun 8, 2012 12:50:05 PM <SYSTEM> Tablespace APPS_UNDOTS1 is 98 percent full
    Jun 8, 2012 12:40:05 PM <SYSTEM> Tablespace APPS_UNDOTS1 is 91 percent full
    Based on some tablespace criteria i want the system to:
    1) generate a corrective action which is not happening (note that on line 2 above it seems like a corrective action was initiated but i don't know how this happened and this is the only occurrence)
    2) run an OS command when the alert is initiated to
    Questions:
    1) why is the system not generating any corrective actions
    2) how can i set OEM to run an OS command
    Thank you for your help

    odie_63 wrote:
    Justin Cave wrote:
    The normal way to approach that sort of requirement would be to use a Java stored procedure.Or a DBMS_SCHEDULER external program with "use_current_session" set to true.
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sched.htm#i1013568
    On 10g+ I'd definitely give this a go.

  • Problem in running Linux command using JavaRuntine

    All,
    When I ran a Linux command in Java Program It does not give a correct output instead it returns null string.
    When I ran the Qsub command( as given in the below program) in Java program I suppose to get Unable to run job: unknown resource "mechhpc1".Exiting. as an output. But it returns null string. It works fine in linux terminal.
    Can you please anyone help me to fix this issue?
    Regards,
    Thamizhannal P
    Source code:
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    public class QSubCmdTest {
         static String Qsub = "sudo -u tce qsub -S /bin/bash ansys_p3 "
                   + "-pe Parallel 3 -l h_rt=3:4:4,ansys=0.333,mechhpc1=0.333 "               
                   + "-a 0804081247.15 /home/tce/c1p4/AnsysParallel";
    /* The aboove command output in terminal (linux machine)
    Unable to run job: unknown resource "mechhpc1".Exiting. */
         static String QSUBcommandOutput = "";
         public static void main(String[] args) {
              System.out.println("Job Submission testing");
              try {
                   Process processExecGenericJobScript = Runtime.getRuntime().exec( new String[]{"/bin/bash","-c",Qsub});
                   //QSUB Command output Reader
                   BufferedReader QSUBcommandOutputReader = new BufferedReader(
                             new InputStreamReader(processExecGenericJobScript
                                       .getInputStream()));
                   System.out.println("Reader "+QSUBcommandOutputReader.readLine());
                   //QSUB command output string
                   String QSUBCommandOutputString = "";
                   while ((QSUBCommandOutputString = QSUBcommandOutputReader
                             .readLine()) != null) {
                        QSUBcommandOutput += QSUBCommandOutputString;
                        QSUBcommandOutput += "\n";
                   System.out.println("QSUBcommandOutput:" + QSUBcommandOutput);
              } catch (Exception exp) {
                   exp.getMessage();
    }

    I would expect error messages to be output on stderr not stdout and you only read stdout. You should read, digest and implement the recommendations in http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html .

  • Not able to create Oracle External Procedure to Run Host Commands

    Trying to follow this article
    http://timarcher.com/node/9
    Its related to
    Oracle External Procedure to Run Host Commands
    steps
    1)mkdir –p /u01/app/usfapp/oracle_external_procs/oracle_host
    2)
    Author is suggesting to create a file
    but header file is missing in very first line... may be not sure..say it is <stdio.h>Create a file named oracle_host.c. The contents of this file will be:
    #include
    int RunCmd(char *cmd)
    return(system(cmd));
    4) Create the file named makefile. The contents of this file will be:
    oracle_host: oracle_host.o
    gcc -shared -o oracle_host.so oracle_host.o
    $ cat makefile
    oracle_host: oracle_host.o
         gcc -shared -o oracle_host.so oracle_host.o
    5)
    Now run the command make
    The output on my server looks like:
    [u01/app/usfapp/oracle_external_procs/oracle_host]
    banner@usfbannerte [TRNG] > make
    gcc -shared -o oracle_host.so oracle_host.o
    here I stuck .. Not able to run this step ]$ make
    gcc -shared -o oracle_host.so oracle_host.o
    /usr/bin/ld: oracle_host.o: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
    oracle_host.o: could not read symbols: Bad value
    collect2: ld returned 1 exit status
    make: *** [oracle_host] Error 1
    Any one has any idea what went wrong
    Any other link related to this is most welcomed.
    Please suggest ...

    hi
    please update
    or
    provide any other link / document for
    Oracle External Procedure to Run Host Commands
    --using c
    Thanks in advance.

  • Ways to run dir command in Process and get Output

    Hello,
    In one of the control in our web application, User can select any directory from his work area and can get list of directories and content of directories i.e. list of files. As working on file object is really slow so the performance is extremely poor. I am thinking of using Process object and run dir command for any directory selected by user and show the directory listing to user.
    Do you guys think it would be possible

    Its always good to work with IO buffer than low level file api. That should be irrelevant to the question as asked (if not then there might be other problems.)This is no way irrelevant but its a fact. Working with Java File api to traverse the content of the directory is really painful. Because we currently use file api to help user to traverse thru her work area.
    BTW, there are two servers. One running the app and the other have all users work areas. User can traverse the workareas content by using something \\server1\workarea1\user1\folder1 etc... in the app to see the content of any folder.A "server" in this context would be an "application" such as something like tomcat. Your client would then ask the "server" for information.
    In your case you are dealing with another file system via the windows remote file system access. So per my question it is not another "server".A server is what providing service to a client and in our case its a app server with a web app in it. The users use the web app to manage their work area(which is another file server).
    The app server and file server and physically two separate machines.
    So again, I am back to my first question, how can run dir command using Process object and get the buffer.
    Till now, I have done this
    ProcessBuilder pb = new ProcessBuilder("cmd", "dir", "c:/");
            pb.directory( new File("C:/temp")); // Or whatever directory you want for cwd
            Map<String,String> env = pb.environment();
            env.put("PATH", "C:/temp");
            try {
                 Process process = pb.start();
                   InputStream inStream = process.getInputStream();
                   new AsyncPipe(process.getErrorStream(), System.out).start();
                 new AsyncPipe(process.getInputStream(), System.out).start();
                 final int returnCode = process.waitFor();
                 System.out.println("Return code is " + returnCode);
                   System.out.println("\nExit value = " + inStream + "\n");
              } catch (Exception e) {
                   e.printStackTrace();
              }However it simply opens command prompt

Maybe you are looking for

  • Can not install Desktop Manager because of DEP.

    Good day BlackBerry users, I've just got myself a BlackBerry Storm 1, and I'd like to install the desktop manager. I've downloaded the install from the site and I tried to install it. In the beginning it's going well, I start it, select my country...

  • Issue with Camera in my Nokia Asha 201

    Hi Nokia Team, I am facing 2 problems with my Nokia Ahsa-201 model (software version current is v11.81) from the time I have bought it. 1. Whenever I click a photo, the screen freezes and the mobile needs to be switched off and restarted. This proble

  • Apple TV Home Sharing Device Limit

    I have 6 brand new Apple TV units and one windows computer running iTunes.  My plan was to use the computer as a media server which I would put our DVD´s, CD´s and existing itunes movies, music and photos on.  We could then access everything from the

  • Date problems

    Guys, I'm getting problem with a date conversion. I don't know what's wrong, but I know that it's wrong.... Could somebody confirm this date for me ??? #3d2d2d2d dateformat = (dd/mm/yyyy hh:mm:ss.mmm am/pm) I'm getting 11/06/2002 04:01:01.000 am, but

  • Anonymous help me it's urgent

    When ever i am running a report, in the job queue always it is showing owner as anonymous. But report is working fine there is no problem in that. But if i will executing the test report which is provided by oracle corporation it is giving me the use