Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过bash脚本将参数传递给正在运行的后台java进程_Java_Linux_Bash - Fatal编程技术网

通过bash脚本将参数传递给正在运行的后台java进程

通过bash脚本将参数传递给正在运行的后台java进程,java,linux,bash,Java,Linux,Bash,我有一个java应用程序,在while循环中使用switch case来执行命令。如何通过bash脚本将参数传递给正在运行的后台java进程?我不想使用socket或webUI传递数据。这是我的密码: public static void main(String[] args) throws IOException { boolean eof = false; Scanner sc = new Scanner(System.in); while (!eof) {

我有一个java应用程序,在while循环中使用switch case来执行命令。如何通过bash脚本将参数传递给正在运行的后台java进程?我不想使用socket或webUI传递数据。这是我的密码:

    public static void main(String[] args) throws IOException {
    boolean eof = false;
    Scanner sc = new Scanner(System.in);
    while (!eof) {
        System.out.println("Enter your command!");
          String data = sc.useDelimiter("\\<end>").next();
        CommandField cmdF = gson.fromJson(data, CommandField.class);
        switch (Command.Parse(cmdF.getCommand())) {
            case LOGIN:
                result = client.isLogged();
                if (result) {
                    System.out.println("successful!");
                } else {
                    System.out.println("failed!");
                }
                break;
        }
publicstaticvoidmain(字符串[]args)引发IOException{
布尔eof=假;
扫描仪sc=新的扫描仪(System.in);
而(!eof){
System.out.println(“输入您的命令!”);
字符串数据=sc.useDelimiter(“\\”).next();
CommandField cmdF=gson.fromJson(数据,CommandField.class);
开关(Command.Parse(cmdF.getCommand())){
案例登录:
结果=client.isloged();
如果(结果){
System.out.println(“成功!”);
}否则{
System.out.println(“失败!”);
}
打破
}

}

您只能通过专用接口将变量传递给正在运行的进程。我认为有以下选项:

  • JMX()
  • HTTP()
  • 插座()
  • 写入临时文件,让流程查看该文件并对更改作出反应

但是,要将参数传递给的程序必须提供接口的实现。。否则,如果进程没有接收选项,就不可能传递任何内容。

请您澄清一下,参数和后台进程是什么意思。该进程是否已经在运行,还是应该启动我已经编辑了我的问题。谢谢@markusww这是bash脚本吗?