没有使用Java从JES SPOOL获取Joblog

时间:2017-03-28 04:32:09

标签: java ftp mainframe jes

我编写了一个Java类,使用FTP将JCL提交给Mainframe JES。代码能够提交JCL,但它没有从JES SPOOL检索JOB日志。

package com.test;



import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.SocketException;

import org.apache.commons.net.ftp.FTPClient;



public class MVSSpool {


    private FTPClient ftp = null;
    private String fUserId,fPassword,fHost,fJobPerfix,replyText;

    public MVSSpool(String fUserId, String fPassword,
            String fHost, String fJobPerfix) {


        this.fUserId = fUserId;
        this.fPassword = fPassword;
        this.fHost = fHost;
        this.fJobPerfix = fJobPerfix;
        ftp = new FTPClient();
    }



    public String getfUserId() {
        return fUserId;
    }

    public void setfUserId(String fUserId) {
        this.fUserId = fUserId;
    }



    public void setfPassword(String fPassword) {
        this.fPassword = fPassword;
    }

    public String getfHost() {
        return fHost;
    }

    public void setfHost(String fHost) {
        this.fHost = fHost;
    }

    public String getfJobPerfix() {
        return fJobPerfix;
    }

    public void setfJobPerfix(String fJobPerfix) {
        this.fJobPerfix = fJobPerfix;
    }





    public void submitJobToSpool(String jobName) throws Exception{

        if (jobName != null){



            connectMVSFtp();
            InputStream is = null;
            BufferedReader br = null;
            String currentLine = null;
            try{
                ftp.retrieveFileStream("'"+jobName.trim()+"'");

                replyText = ftp.getReplyString();
                System.out.println("some " + replyText);

                String[] replies = ftp.getReplyStrings();
                String remoteFileName = replies[replies.length - 1].split(" ")[2]+ ".2";


                for(String rep :replies){

                    System.out.println("checking .. " + rep);
                }

                Thread.sleep(10000);

                System.out.println("getting sysout of the file " + remoteFileName);

                is = ftp.retrieveFileStream(remoteFileName);
                replies = ftp.getReplyStrings();
                for(String rep :replies){

                    System.out.println("checking 2 .. " + rep);
                }

                if (is != null){

                    br = new BufferedReader(new InputStreamReader(is));


                    while((currentLine = br.readLine()) != null){

                        System.out.println(currentLine);
                    }

                }

                ftp.completePendingCommand();

                System.out.println("Done...");
            }catch(Exception e){
                e.printStackTrace();
                throw new Exception("Error in submitting Job  from spool");
            }finally{
                ftp.disconnect();

                if(br != null){
                    br.close();
                }
                if(is != null){
                    is.close();
                }
            }


        }
    }

    /**
     * @throws SocketException
     * @throws IOException
     */
    private void connectMVSFtp() throws SocketException, IOException {

        // check if the required parameters are set already
        if (fUserId == null | fPassword == null | fHost == null){

        }else{
            ftp.connect(fHost);

            replyText = ftp.getReplyString();
            System.out.println(replyText);

            // login using user name and password

            ftp.login(fUserId, fPassword);
            replyText = ftp.getReplyString();
            System.out.println(replyText);

            // point the FTP to JES spool
            ftp.site("filetype=jes");
            replyText = ftp.getReplyString();
            System.out.println(replyText);
        }
    }


}

我收到消息

230 XXXXX已登录。工作目录是" XXXXX。"。

接受了200 SITE命令

一些125-提交工作' XXXXX.XXXX.JCLLIB(ALIAS)' FIXrecfm 80 125 JOB07591完成后,将检索其输出

检查.. 125-提交作业' XXXXX.XXXX.JCLLIB(ALIAS)' FIXrecfm 80 检查.. 125 JOB07591完成后,将检索其输出 获取文件JOB07591.2的sysout 检查2 .. 550没有可用于JOB07591的假脱机文件,JesPutGet已中止 做... enter code here

0 个答案:

没有答案