Problem in Displaying FTP Transferred Files ... (Square Characters... etc)
Hi All,
I would like to ask regarding the format of the text files that I transferred or copied from another computer thru FTP.
Example of which is:
3890001604AM0 - With Shipping Order DT Actual Transactions ... Joji to provide GMUS.<Square Character>
3890003011NZ0 - With Shipping Order DT Actual Transactions ... Joji to provide GMUS.<Square Character>
3890003012NZ0 - With Shipping Order DT Actual Transactions ... Joji to provide GMUS.<Square Character>
3890003014NZ0 - With Shipping Order DT Actual Transactions ... Joji to provide GMUS.<Square Character>
I think this<Square Character> indicates <next line>, but I need to remove this<Square Character> at the same time set the format of the text file to: (4 Lines)
3890001604AM0 - With Shipping Order DT Actual Transactions ... Joji to provide GMUS.
3890003011NZ0 - With Shipping Order DT Actual Transactions ... Joji to provide GMUS.
3890003012NZ0 - With Shipping Order DT Actual Transactions ... Joji to provide GMUS.
3890003014NZ0 - With Shipping Order DT Actual Transactions ... Joji to provide GMUS.
Another thing:
ACSUS08 - With Sales Order Actual Transactions ... Jeannie to provide GMUS.<Square Character>
HNXUS30 - With Sales Order Actual Transactions ... Jeannie to provide GMUS.<Square Character>
This is displayed in one line only. The original is two lines without the<Square Character>. Here is the contents of the text file without the<Square Character>:
ACSUS08 - With Sales Order Actual Transactions ... Jeannie to provide GMUS.
HNXUS30 - With Sales Order Actual Transactions ... Jeannie to provide GMUS.
I noticed also that... when I copy and paste the contents with the<Square Character> here in the forums... The format problem was gone and I cannot see the<Square Character>... but instead it goes to the next line as what It should be.
Any Idea how to deal with this problem?br>
Please Help?br>
MaDz
in FTP type "ascii" before you transfer the file.
> in FTP type "ascii" before you transfer the file.I would have thought that the OP should use binary mode!
I am using FTP command in windows xp:
ftp -n -s:SUB_COMMANDS_FILE IP_ADDRESS
Contents of SUB_COMMANDS_FILE:
-
user USERNAME PASSWORD
binary
cd /appsvg3/i2doleproj/prod/intg/clogFileServer/clog_datafiles/ip/dp/dpLoadingErrors
get InvalidSalesName_Errors.txt
get InvalidProduct_Errors.txt
get ConversionFactor_Errors.txt
get DualParent_Family_FruitType.csv
get DualParent_Family_Group.csv
get DualParent_Group_Line.csv
get DualParent_Line_Class.csv
get DualParent_PackSize_Line.csv
get DualParent_PID_Family.csv
get DualParent_PID_PackSize.csv
get DualParent_UPC_Line.csv
get DualParent_UPC_PID.csv
y
Quit
-
Is ascii much slower compared to binary?
I need to preserve the contents and the format as much as possible in transferring it from the remote server down to my local pc.?
Got it dude... I just replace the binary into ascii... I thought transferring it through ascii will be slower than binary... hehe
Thanks a lot dude.. hehe
1 burden down ... hehe
Do you guys know how to run the FTP command in java? I am having this problem now?It seemed that it doesn't stop although I already transferred the file from remote server to my local.
Here is the simple program I created just to test the transfer:
-
public void getFiles(String configFile, String host,FileWriter writer) throws IOException{
//Command: ftp -n -s:test.cfg 192.168.3.1
try{
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("ftp -n -s:" + configFile.trim() + " " + host.trim());
InputStream stderr = proc.getErrorStream();
InputStreamReader isr = new InputStreamReader(stderr);
BufferedReader br = new BufferedReader(isr);
String line = null;
while ( (line = br.readLine()) != null)
System.out.println("Error Line: " + line);
int exitVal = proc.waitFor();
writer.write("FTP Transfer: Remote to Local - Done!");
writer.write("Process exitValue: " + exitVal);
writer.close();
} catch (Throwable t){ t.printStackTrace(); }
}
-
I do not know what part in the code is the problem... :-( I am just new to java (I am previously handling VB application - no choice).
> > in FTP type "ascii" before you transfer the file.
>
> I would have thought that the OP should use binary
> mode!
Just the opposite binary mode leaves unix newlines unix newlines, where ascii mode converts unix newlines to dos newlines (or dos to unix or unix to mac or mac to dos or etc, etc, etc) among other things. That black square, at least every time I've seen it) has been a unix newline seen in notepad (wordpad and word and other/better editors can handle it, but not notepad).
Edit: I am also fairly sure that you know this, but I still typed it (for the OPs benefit if nothing else).
Edit again: Also note, that this is only good for simple text files (including csv, xml, html, and the like). For anything other than simple text file always, always use binary or you will hose the file. But for text you nearly always want to use ascii mode.
Google for an FTP API (I think the apache commons net package has one). It will make your life so much easier.
http://jakarta.apache.org/commons/net/ http://www.enterprisedt.com/products/edtftpj/overview.html
I already have downloaded the package but I am afraid I cannot find some sample programs on how to use Jakarta Commons Net FTP ... :-(
We are only limitted to 5 sites here and I have a hard time looking for sample programs considering this 5 sites limitation policy of the company.
Running the windows xp FTP command in DOS is just fine it is also fast but... I have problems calling it in my java program.?it seemed to be stucked hehe...
Thanks a lot dude. God bless
> Edit again: Also note, that this is only good for
> simple text files (including csv, xml, html, and the
> like). For anything other than simple text file
> always, always use binary or you will hose the file.
> But for text you nearly always want to use ascii
> mode.
I ALWAYS use binary mode since I never ever want the transfer process to modify the file content in any way. If I want to change the eol I will do it myself.
Many of the text display problems that are seen in these forums are due to people trying to use Notepad to look at the content.
> I ALWAYS use binary mode since I never ever want the
> transfer process to modify the file content in any
> way. If I want to change the eol I will do it
> myself.
>
> Many of the text display problems that are seen in
> these forums are due to people trying to use Notepad
> to look at the content.
That's fine for you, and many others. But when you are dealing with things that are purely ascii text, and one of the OSes does not use some funky character tabling (thinking ECB) then I see no problem, whatsoever, in allowing the FTP program to convert the text format to the native system.
Now adays, for most programs, the line endings don't make a difference, but a while back, you had large problems in scripts and other programs using information from a text file copied from another OS in bin mode. It was correctable by running dos2unix/unix2dos or something similiar, but it was still a pain. That is where I got the habit from, and I will continue to promote it.
Thanks a lot for the ideas guys?br>God bless to you all, May the force be with you always heheMaDz