Operating System - Linux
1827817 Members
2011 Online
109969 Solutions
New Discussion

corrupt files after ftp transfer

 
SOLVED
Go to solution
'chris'
Super Advisor

corrupt files after ftp transfer

hi

I transfer TEXT files via ftp in ascii mode
from linux to the WIN2000 ftp server using a perlscript:
-----------------------------------------------
my $ftp = Net::FTP->new ($server, Timeout => 9000, Debug => 3);
$ftp or die "$server: cannot connect: $@";
$ftp->login ($user,$passwd) or
die "$_: Could not login: " . $ftp->message;
# Put file
$ftp->put ($file) or
die "$server: cannot put $file: " . $ftp->message;
$ftp->quit;
-----------------------------------------------
but files after transfer are corrupt.
I get between text lines someting like:
 03
or some special not standard symbols, that I cannot copy to the browser.

knows someone, what reason could be and how can I fix this problem ?
I cannot transfer these files in binary mod
7 REPLIES 7
KapilRaj
Honored Contributor

Re: corrupt files after ftp transfer

i am not good in perl .. but ftp needs to be told taht u r trying to transfer an ascii file not binary .. or vice versa

ftp > bin or ascii

Kaps
Nothing is impossible
'chris'
Super Advisor

Re: corrupt files after ftp transfer

I've tried to put:

$ftp->ascii();

but it still doesn't help.

KapilRaj
Honored Contributor

Re: corrupt files after ftp transfer

i think u r trying a binary can u try with "bin"

Kaps
Nothing is impossible
'chris'
Super Advisor

Re: corrupt files after ftp transfer

but I must send these files in ascii mode !
Abdul Rahiman
Esteemed Contributor
Solution

Re: corrupt files after ftp transfer

Chris,

I bet what you are seeing on Windows is the unix control characters. It is better to convert the unix format file to dos format before you ftp the files. You can do this with simple linux command called "unix2dos",

eg: #unix2dos myfile.txt --> would convert the linux text file into dos format and replace it.

To see more options with unix2dos,
# man unix2dos
use -n option to write a new file instead of replacing it.

In your scenario, you may put a shell script first to do the format conversion and call the perl script from the shessl script.

regds,
Abdul.
No unix, no fun
'chris'
Super Advisor

Re: corrupt files after ftp transfer

thanks !
'chris'
Super Advisor

Re: corrupt files after ftp transfer

firewall was a problem, because our firewall doesn't support autosense.

I set the port on the sitch to half duplex and now it works without any problems.