无法接收来自 DSPLIBL 的输出(as400.access 包)
Can't receive output from DSPLIBL (as400.access package)
我正在尝试使用 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 library name 工作正常,它 returns 是一条输出消息。无效的命令还有 returns 条消息说输入无效。只是 DSPLIBL 没有给我输出。
有什么问题吗?
docs 具体说 CommandCall
allows a Java™ program to call a non-interactive IBM® i command.
DSPLIBL 是一个交互式命令。
您为 CRTLIB 成功返回的 "output" 是该命令返回的完成消息。
我正在尝试使用 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 library name 工作正常,它 returns 是一条输出消息。无效的命令还有 returns 条消息说输入无效。只是 DSPLIBL 没有给我输出。
有什么问题吗?
docs 具体说 CommandCall
allows a Java™ program to call a non-interactive IBM® i command.
DSPLIBL 是一个交互式命令。
您为 CRTLIB 成功返回的 "output" 是该命令返回的完成消息。