English 中文(简体)
如何从 Java开一个UNIX终端,并向它发出指挥?
原标题:How do i run a UNIX terminal from Java and send commands to it?

关于这个专题,以下准则:


    Process proc = null;
    try {
        String[] cmdss= {"gnome-terminal"};


        proc = Runtime.getRuntime().exec(cmdss, null, wd);
    } catch (IOException e) {
        e.printStackTrace();
    }

班图。

我在管理术语后如何向终点站发出指挥?

例如:管理终点站,并指挥“ls”等。

最佳回答

您可提供<条码>gnome-terminal,在指挥线上可选择实施什么。

gnome-terminal -e /my/fortran/program

<代码>-x选项给你带来了大致相同的惠益,但你可以将指挥线分开使用。

* E/CN.15/2009/1。 在将方案“标准投入和产出”与终点站连接起来的同时,将方案与任择论点一起操作。 因此,用户可以与终端站适当互动。

例:

gnome-terminal -x bash -c "ls; echo  <enter> ; read"

这将打开终端并运行“program”bash.bash, 2<>m>. 2<>m> > > >. <代码>-c 备选办法使下个论点得以分类和执行。 这将称作ls,然后echo >,然后read, 等待交接钥匙。

在 Java,你必须将论点适当分为如下几个方面:

String cmd[] = {"gnome-terminal", "-x", "bash", "-c", "ls; echo  <enter> ; read" };
问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...