I am trying to FTP a JCL txt file to mainframe:
// Connect to the server
ftp.connect(host);
replyText = ftp.getReplyString();
System.out.println(replyText);
// Log into the server
ftp.login(userId, password);
replyText = ftp.getReplyString();
System.out.println(replyText);
// Tell the server to use the JES interface
ftp.sendSiteCommand("FILETYPE=JES");
replyText = ftp.getReplyString();
System.out.println(replyText);
//read JCL file in input stream
FileInputStream fileStream = new FileInputStream(file);
String originalFileName = "ca7jcl.txt";
ftp.setFileType(FTP.ASCII_FILE_TYPE);
//store the JCL file
ftp.storeFile(host, fileStream);
replyText = ftp.getReplyString();
System.out.println(replyText);
but getting 250-It is known to JES as *UNKNOWN how can i resolve this?
I am assuming that you want to run your JCL text file when FTP'ed.
Enclose try {}
and catch {}
block (if not done).
Here's the code (This works for me):
// FTPClient ftp = new FTPClient(); Assumed in your code
//Connect to the server
try
{
ftp.connect(host);
replyText = ftp.getReplyString();
System.out.println(replyText);
} catch (Exception e) { e.printStackTrace () ; }
//Login to the server
try
{
ftp.login(userId, password);
replyText = ftp.getReplyString();
System.out.println(replyText);
} catch (Exception e) { e.printStackTrace(); }
// Tell the server to use the JES interface
try
{
// Instead of sendSiteCommand()
// ftp.sendSiteCommand("FILETYPE=JES");
// Try site() with everythng in lowercase
ftp.site ("filetype=jes") ;
String replyText = ftp.getReplyString() ;
System.out.println (replyText) ;
} catch (Exception e) { e.printStackTrace(); }
//Submit the job from the text file.Use \\ to avoid using escape notation
try
{
//read JCL file in input stream
//String originalFileName = "ca7jcl.txt";
String path = "" //Store your file's absolute path here
FileInputStream fileStream = new FileInputStream(path);
//store the JCL file
ftp.storeFile(host, fileStream);
replyText = ftp.getReplyString();
System.out.println(replyText);
} catch (Exception e) { e.printStackTrace(); }
Let us know if this helped. :)