无法从DSPLIBL接收输出(as400.access包)

问题描述 投票:1回答:1

我正在尝试使用java连接到AS / 400服务器,并希望运行一些简单的命令。

我的进口是:

    import com.ibm.as400.access.AS400;
    import com.ibm.as400.access.AS400Message;
    import com.ibm.as400.access.CommandCall;

这是我到目前为止:

    AS400 as400 = null;
    Scanner scanner = new Scanner(System.in);
    try {
        as400 = new AS400(host);            
        as400.setUserId(user);
        as400.setPassword(pass);
        CommandCall cmd = new CommandCall(as400);


        while(true) {
            System.out.println("Ready for input, type \"quit\" to end session");
            String commandStr = scanner.nextLine();
            System.out.println("Command entered: " + commandStr);
            if(commandStr.equals("quit")) {
                break;
            }
            System.out.println("Executing: " + commandStr);

            boolean success = cmd.run(commandStr.toUpperCase());
            System.out.println("Finished execution");
            if (success) {  
                System.out.println("Command Executed Successfully.");
            }else{
                System.out.println("Command Failed!");
            }
            // Get the command results
            System.out.println("Getting output");
            AS400Message[] messageList;
            messageList  = cmd.getMessageList();
            for (AS400Message message : messageList){
               System.out.println(message.getText());
            }


        }                       
    }catch(UnknownHostException uh){
        System.out.println("Unknown host");         
    }catch(Exception e) {
        e.printStackTrace();
    }finally{
        scanner.close();
        try {

            as400.disconnectAllServices();

        }catch(Exception e) {}
    }

当我尝试运行DSPLIBL时:我得到一个空白输出。

Ready for input, type "quit" to end session
dsplibl
Command entered: dsplibl
Executing: dsplibl
Finished execution
Command Executed Successfully.
Getting output
Ready for input, type "quit" to end session

然而其他一切似乎都没问题。 CRTLIB库名称工作正常,它返回一个输出消息。无效命令还会返回表示输入无效的消息。这只是DSPLIBL没有给我一个输出。

关于什么是错的任何想法?

java ibm-midrange
1个回答
1
投票

docs特别指出CommandCall

允许Java™程序调用非交互式IBM®i命令。

DSPLIBL是一个交互式命令。

您为CRTLIB成功返回的“输出”是该命令返回的完成消息。

看看getUserLibraryList() method of the Job object

© www.soinside.com 2019 - 2024. All rights reserved.