我正在尝试使用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没有给我输出。
关于什么是错的任何想法?
答案 0 :(得分:1)