简体   繁体   English

如何在Oracle VM上运行命令

[英]how run a command on Oracle VM

We have oracle virtual machine installed in our solaris machine. 我们在solaris机器中安装了oracle虚拟机。 (we need waptpro tool which can be installed only on windows). (我们需要只能在Windows上安装的waptpro工具)。 So, we have this tool installed on oracle virtual machine. 因此,我们在oracle虚拟机上安装了此工具。

Now I have a java code on my solaris machine. 现在,我的solaris机器上有一个Java代码。 I need to execute waptpro tool from solaris machine. 我需要从solaris机器执行waptpro工具。 If there any command where i can run the command on oracle virtual machine from solaris I can integrate this in my javacode 如果有任何命令可以在solaris的oracle虚拟机上运行该命令,则可以将此命令集成到我的javacode中

So, please let me know if anyone know how to execute a command on oracle virtual machine from solaris. 因此,请让我知道是否有人知道如何在solaris的oracle虚拟机上执行命令。

This is something that is easy in the simplest case but require quite a bit of elbow grease to get right for all cases. 在最简单的情况下,这很容易,但需要大量的肘部润滑脂才能适合所有情况。

From http://www.rgagnon.com/javadetails/java-0014.html for Java 1.5 and later (adapt the command as needed): 在Java 1.5及更高版本的http://www.rgagnon.com/javadetails/java-0014.html中(根据需要调整命令):

import java.io.*;
import java.util.*;

public class CmdProcessBuilder {
  public static void main(String args[])
     throws InterruptedException,IOException
  {
    List<String> command = new ArrayList<String>();
    command.add(System.getenv("windir") +"\\system32\\"+"tree.com");
    command.add("/A");

    ProcessBuilder builder = new ProcessBuilder(command);
    Map<String, String> environ = builder.environment();
    builder.directory(new File(System.getenv("temp")));

    System.out.println("Directory : " + System.getenv("temp") );
    final Process process = builder.start();
    InputStream is = process.getInputStream();
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);
    String line;
    while ((line = br.readLine()) != null) {
      System.out.println(line);
    }
    System.out.println("Program terminated!");
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM