I trying to get free space on my database disk. I had test of many ways without success. This is the last i tried. I create a JAVA SOURCE in oracle which invokes Runtime.getRuntime().exec() in java. The code is:
CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED TEST.DISKS_FREE as
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
public class diskfreespace
{
public static String loaddisk() throws IOException,InterruptedException
{
//Process p=Runtime.getRuntime().exec("cmd.exe /c wmic /node:\"%COMPUTERNAME%\" LogicalDisk Where DriveType=\"3\" Get DeviceID,FreeSpace|find /I \":\"");
Process p=Runtime.getRuntime().exec("cmd.exe /c dir|find \"bytes free\"");
//Process p=Runtime.getRuntime().exec("cmd /c dir");
//p.waitFor();
BufferedReader reader=new BufferedReader(
new InputStreamReader(p.getInputStream())
);
String line;
String result ="";
while((line = reader.readLine()) != null)
{
result+="\n"+line;
}
return result;
}
}
As you can see, this method call to command cmd.exe /c dir|find "bytes free". In java environment, this code works perfectly, returning C: 13741621248, but in oracle it never send a response. I tried with other command cmd /c dir list directories for both cases.
Any idea? Regards.
Aucun commentaire:
Enregistrer un commentaire