sladej
asked on
sun.net.ftp get file from mainframe
I am trying to get a file from a mainframe. I continue to get a filenotfound exception. When I type the command into a command prompt, I get the file every time. I was wondering if anyone knows if this api can be used with a java application to get a file from a mainframe? Here is a small snippet of what I am doing. Any suggestions or help is greatly needed. thanks,
//Get FTP properties
String ftpHost = getStringProperty(CONFIG_K EY_FTP_HOS T);
String ftpId = getStringProperty(CONFIG_K EY_FTP_ID) ;
String ftpPassword = getStringProperty(CONFIG_K EY_FTP_PAS SWORD);
//Make FTP connection
FtpClient ftp = new FtpClient();
try
{
ftp.openServer(ftpHost);
ftpServerOpened = true;
ftp.login(ftpId, ftpPassword);
}
catch (Throwable t)
{
m_logger.error("Unable open FTP session on " + ftpHost + " for user " + ftpId,t);
RenewalException renewalException = new RenewalException("Unable open FTP session on " + ftpHost + " for user " + ftpId,t);
renewalException.setRootCa use(t);
renewalException.setAlarmN ame("FTP ERROR");
renewalException.setAlarmT ime(new Date());
throw renewalException;
}
//FTP the file to Eart
boolean successfulFileTransfer = false;
//Copy the eArt file we ceated above to the FTP destination.
TelnetInputStream tis = null; // Does special treatment of line-endings
try
{
ftp.binary();
//ftp.cd(ftpDirectory);
tis = ftp.get(pdfName);
//Get FTP properties
String ftpHost = getStringProperty(CONFIG_K
String ftpId = getStringProperty(CONFIG_K
String ftpPassword = getStringProperty(CONFIG_K
//Make FTP connection
FtpClient ftp = new FtpClient();
try
{
ftp.openServer(ftpHost);
ftpServerOpened = true;
ftp.login(ftpId, ftpPassword);
}
catch (Throwable t)
{
m_logger.error("Unable open FTP session on " + ftpHost + " for user " + ftpId,t);
RenewalException renewalException = new RenewalException("Unable open FTP session on " + ftpHost + " for user " + ftpId,t);
renewalException.setRootCa
renewalException.setAlarmN
renewalException.setAlarmT
throw renewalException;
}
//FTP the file to Eart
boolean successfulFileTransfer = false;
//Copy the eArt file we ceated above to the FTP destination.
TelnetInputStream tis = null; // Does special treatment of line-endings
try
{
ftp.binary();
//ftp.cd(ftpDirectory);
tis = ftp.get(pdfName);
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
When you do a ftp.cd(), you're merely changing the location from where listings of contents will be provided from.
ASKER
The pdfName is B5342SGU.G5342.PDF00903.C0 40322.DATA
Why no pdf extension? If that's in the root directory, try
final String pdfName = "/B5342SGU.G5342.PDF00903. C040322.DA TA";
final String pdfName = "/B5342SGU.G5342.PDF00903.
ASKER
I have tried :
without doing a ftp.cd();
and with
ftp.cd(B5342SGU.G5342);
ftp.cd(B5342SGU.G5342.PDF00903);
all with ftp.get(B5342SGU.G5342.PDF00903.C040322.DATA);
without doing a ftp.cd();
and with
ftp.cd(B5342SGU.G5342);
ftp.cd(B5342SGU.G5342.PDF00903);
all with ftp.get(B5342SGU.G5342.PDF00903.C040322.DATA);
Please print out here what the listing is from a 'real' ftp client of that file (of course you'll have to have read rights on it too):
Is "." really the file separator? Have your tried using "/"?
As in:
ftp.get("/B5342SGU/G5342/PDF00903/ C040322/DA TA");
The ftp standards document specifies the file separator as being "/"
As in:
ftp.get("/B5342SGU/G5342/PDF00903/
The ftp standards document specifies the file separator as being "/"
ASKER
I don't know if this is what you are talking about but this is what I get when ftping from the command prompt:
User (uhc1ip.uhc.com:(none)): t534201
331 Send password please.
Password:
230 T534201 is logged on. Working directory is "T534201.".
ftp> get 'B5342SGU.G5342.PDF00903.C 040322.DAT A'
200 Port request OK.
125 Sending data set B5342SGU.G5342.PDF00903.C0 40322.DATA
250 Transfer completed successfully.
ftp: 97867 bytes received in 0.36Seconds 271.10Kbytes/sec.
ftp>
User (uhc1ip.uhc.com:(none)): t534201
331 Send password please.
Password:
230 T534201 is logged on. Working directory is "T534201.".
ftp> get 'B5342SGU.G5342.PDF00903.C
200 Port request OK.
125 Sending data set B5342SGU.G5342.PDF00903.C0
250 Transfer completed successfully.
ftp: 97867 bytes received in 0.36Seconds 271.10Kbytes/sec.
ftp>
>>Working directory is "T534201.".
In that case it should be
final String pdfName = "/T534201/B5342SGU.G5342.P DF00903.C0 40322.DATA ";
In that case it should be
final String pdfName = "/T534201/B5342SGU.G5342.P
But just to be sure, instead of
>>get 'B5342SGU.G5342.PDF00903.C 040322.DAT A'
can you do
>pwd
and tell us the ouput
>>get 'B5342SGU.G5342.PDF00903.C
can you do
>pwd
and tell us the ouput
That's just
pwd
btw
pwd
btw
ASKER
Password:
230 T534201 is logged on. Working directory is "T534201.".
ftp> pwd
257 "'T534201.'" is working directory.
ftp>
230 T534201 is logged on. Working directory is "T534201.".
ftp> pwd
257 "'T534201.'" is working directory.
ftp>
OK then it should be
final String pdfName = "/T534201/B5342SGU.G5342.P DF00903.C0 40322.DATA
If that still produces the same error, can you post the result of
ls -l B5342SGU.G5342.PDF00903.C0 40322.DATA
final String pdfName = "/T534201/B5342SGU.G5342.P
If that still produces the same error, can you post the result of
ls -l B5342SGU.G5342.PDF00903.C0
ASKER
Alright, I'll go give that a try and post the result in a bit.
thanks,
thanks,
Hmm, based on the output from the ftp client it is more likely that the following will work:
final String pdfName = "/T534201./B5342SGU.G5342. PDF00903.C 040322.DAT A";
Note the period at the end of the initial directory name.
final String pdfName = "/T534201./B5342SGU.G5342.
Note the period at the end of the initial directory name.
>>Note the period at the end of the initial directory name
Oh yes - that's pretty odd
Oh yes - that's pretty odd
ASKER
I tried it both ways: "/T534201./B5342SGU.G5342. PDF00903.C 040322.DAT A and /T534201/B5342SGU.G5342.PD F00903.C04 0322.DATA
both ways gave me the following:
sun.net.ftp.FtpProtocolException: RETR B5342SGU.G5342.PDF00903.C0 40322.DATA
both ways gave me the following:
sun.net.ftp.FtpProtocolException: RETR B5342SGU.G5342.PDF00903.C0
My only other suggestion would be to remove the initial "/": "T534201./B5342SGU.G5342.P DF00903.C0 40322.DATA "
And this may be my last one too: ;-)
final String pdfName = "~/B5342SGU.G5342.PDF00903 .C040322.D ATA
final String pdfName = "~/B5342SGU.G5342.PDF00903
ASKER
I tried T534201./B5342SGU.G5342.PD F00903.C04 0322.DATA and got the ftpprotocolexception
with "~/B5342SGU.G5342.PDF00903 .C040322.D ATA, I got the original error:
RETR B5342SGU.G5342.PDF00903.C0 40322.DATA : 550 Data set T534201.B5342SGU.G5342.PDF 00903.C040 322.DATA not found
I wonder if this api will work at all with the mainframe. It doesn't seem to understand the structure in which files are store.
with "~/B5342SGU.G5342.PDF00903
RETR B5342SGU.G5342.PDF00903.C0
I wonder if this api will work at all with the mainframe. It doesn't seem to understand the structure in which files are store.
ASKER
I tried this from the command prompt:
ls -l B5342SGU.G5342.PDF00903.C0 40322.DATA
and got
ftp> ls -l B5342SGU.G5342.PDF00903.C0 40322.DATA
200 Port request OK.
550 No data sets found.
ls -l B5342SGU.G5342.PDF00903.C0
and got
ftp> ls -l B5342SGU.G5342.PDF00903.C0
200 Port request OK.
550 No data sets found.
ASKER
I did a ls and got:
ftp> ls 'B5342SGU.G5342.PDF00903.C 040322.DAT A'
200 Port request OK.
125 List started OK
'B5342SGU.G5342.PDF00903.C 040322.DAT A'
250 List completed successfully.
ftp: 40 bytes received in 0.00Seconds 40000.00Kbytes/sec.
ftp> ls 'B5342SGU.G5342.PDF00903.C
200 Port request OK.
125 List started OK
'B5342SGU.G5342.PDF00903.C
250 List completed successfully.
ftp: 40 bytes received in 0.00Seconds 40000.00Kbytes/sec.
It certainly looks pretty odd to me, but you'd think if you can connect to it with FTP there shouldn't be any protocol problems
Yes - to be fair to the server,
ls -l
is beyond the protocol but usually works on Unix servers. Should have guessed, but i wanted to see the *nix file permissions originally. Anyway, i think the perms issue is academic.
ls -l
is beyond the protocol but usually works on Unix servers. Should have guessed, but i wanted to see the *nix file permissions originally. Anyway, i think the perms issue is academic.
>> 550 No data sets found.
The above leads me to believe that this 'ftp' implementation is VERY custom. Can you verify the ftp server make and version?
The above leads me to believe that this 'ftp' implementation is VERY custom. Can you verify the ftp server make and version?
ASKER
I found the answer of why it is not working.
I needed to add a ftp.cd("//"); after I changed the type to binary. I am still not sure why but now it works. Thanks you both for your help. Do either of you have any problem with me splitting the points between you?
thanks again.
I needed to add a ftp.cd("//"); after I changed the type to binary. I am still not sure why but now it works. Thanks you both for your help. Do either of you have any problem with me splitting the points between you?
thanks again.
>>Do either of you have any problem with me splitting the points between you?
Not i ;-)
>>I needed to add a ftp.cd("//");
Shouldn't be necessary (as indeed the second forward slash isn't)
Not i ;-)
>>I needed to add a ftp.cd("//");
Shouldn't be necessary (as indeed the second forward slash isn't)
nor i... :-)
8-)
=-)