Re: ASCII text garbled on FTP download?

From: root (root_at_home.com)
Date: 04/16/04


Date: Fri, 16 Apr 2004 15:57:50 +0100

On Fri, 16 Apr 2004 02:55:02 -0700, Bill S. wrote:

> Thanks for the response. Ok basically my question is about carriage
> returns. What I meant in they "never come out of linux" is this: I
> sit here at home on my Windows XP machine. I want to move my files,
> say 1.html, 1.gif and 1.cgi, from Server 1 to Server 2, both 3,000
> miles away from me, and away from each other. The files are in /home
> on Server 1 and I want to put them in the same location on Server 2
> (/home).
>
> I ssh into Server 1. I cd /home, and type "tar cvf compressedfile *"
>
> I exit.
>
> I ssh into Server 2. I:
> mkdir /home
> cd / home
> ftp
> open Server 1, login, cd /home
> get compressedfile
> exit
>
> Ok, so then I "tar xvf compressedfile"
>
> I have then, in Server 2's /home, 1.html, 1.gif, and 1.cgi
>
> I exit ssh, all done.
>
> Ok, I am still at my Windows XP pc as the weather is bad and I don't
> want to go outside. I have no umbrella, and I hate getting drenched.
>
> I then run ws_ftp. I have 1.html, 1.gif and 1.cgi in my ws_ftp
> directory. Originally, 7 years ago, I uploaded them to Server 1,
> 1.gif in binary and 1.cgi and 1.html in ASCII.
>
> So to remember what 1.cgi looked like, I go to view, & it's opened in
> notepad.exe. I see:
>
> Version Info ###
> $YaBBversion = '1 Gold - SP 1.1';
> $YaBBplver = '1 Gold - SP 1.1';
>
> if( $ENV{'SERVER_SOFTWARE'} =~ /IIS/ ) {
> $yyIIS = 1;
> $0 =~ m~(.*)(\\|/)~;
> $yypath = $1;
> $yypath =~ s~\\~/~g;
> chdir($yypath);
> push(@INC,$yypath);
> }
>
> ### Requirements and Errors ###
> use CGI qw(header cookie); # so we can use the header and cookie
> printing
> use CGI qw/:standard/;
> $CGI::HEADERS_ONCE = 1; # Kill redundant headers
> require "Settings.pl";
> require "$language";
> require "$sourcedir/Subs.pl";
> require "$sourcedir/Load.pl";
> require "$sourcedir/Security.pl";
>
>
> I ftp into Server 1, download 1.cgi in ASCII and view it, and see the
> same as 1.cgi originally on my Windows XP, from 7 years ago.
>
> I ftp into Server 2, download the file in ASCII, the same way. I see
> something a bit like:
>
> Version Info ###$YaBBversion = '1 Gold - SP 1.1';$YaBBplver = '1 Gold
> - SP 1.1';
> if( $ENV{'SERVER_SOFTWARE'} =~ /IIS/ ) { $yyIIS = 1; $0 =~
> m~(.*)\\|/)~; $yypath = $1; $yypath =~
> s~\\~/~g; chdir($yypath); push@INC,$yypath);}### Requirements and
> Errors ###use CGI qw(header cookie); # so we can use the header and
> cookie printinguse CGI qw/:standard/;$CGI::HEADERS_ONCE = 1; # Kill
> redundant headers require "Settings.pl";require "$language";require
> "$sourcedir/Subs.pl";require "$sourcedir/Load.pl";require
> "$sourcedir/Security.pl"; # Those who write software only for pay
> should go hurt some other field. # - Erik Naggum
> &LoadCookie;
>
>
> When I pasted the above directly here, in this window, it formatted
> like how it looks from Server 1 or on my Windows XP. However, sitting
> in notepad.exe, even cut and re-pasted, the formatting is garbled, in
> that the carriage returns do not display well.
>
> So I was wondering why this was the case and if there is anything I
> can do about this, rather than cutting out the ill formatted ascii
> files, pasting them somewhere to get the formatting back, then
> repasting them into notepad, and re-uploading them.
>
> Thanks!!

Yes, you can zip the files up on the linux machine, ftp them in binary and
unzip them on the windows machine. ("man zip" NOT gzip)

If you want to edit the files on windows they must always be in CR LF
(DOS) format.... so use

"unix2dos 1.cgi" etc on the linux machine to force the files into CR+LF
terminated lines (apache wont care). Then ALWAYS transfer ALL files in
binary.

Or you can convert a CR to CR+LF file on windows using the following trick.

Start,run,cmd

"edit 1.cgi"
add 1 space,backspace 1 space <ALT> F X <Return>

Thats file,save,yes write changes. The file is now CR+LF terminated lines
and works in windows.

As I have already mentioned the problem is probably the ftp client or
configuration of one of the ftp servers. As a rule don't move things
around in ASCII.

If you make it all CR+LF formatted and move it around in binary the
problem goes away ...

I would ask why anybody would write cgi sitting using notepad on an XP
machine anyway !!!!

If you cant live without XP use vmware to run a linux inside it, then you
can write,edit and test cgi content... or dual boot the laptop... or even
use knoppix to CD boot the laptop into a linux environment. Why would you
want to edit the files in one place and run them in another, sounds a slow
and clunky way of working to me.

I've worked in a mixed windows/linux/unix world for years with none of
these problems - you simply need to re-consider the best way to work -
moving files around one at a time is a symptom of an ill-planned work
pattern.

I use a local linux machine to run apache and cgi - I connected to it
using a laptop running knoppix and wireless networking when im not at my
desk and I only ftp complete projects in binary... i've not had problems
at all.

Jon



Relevant Pages

  • Re: Problem about Window Xp SP2 firewall and the buildin FTP command
    ... Problem about Window Xp SP2 firewall and the buildin FTP ... I find a problem that if running multiple FTP command at the same ... Windows XP SP2 to limit Max Connections/sec ...
    (microsoft.public.windowsxp.general)
  • Problem about Window XP SP2 firewall and the buildin FTP command
    ... Problem about Window Xp SP2 firewall and the buildin FTP ... I find a problem that if running multiple FTP command at the same ... Windows XP SP2 to limit Max Connections/sec ...
    (microsoft.public.windowsxp.perform_maintain)
  • Re: Problem about Window Xp SP2 firewall and the buildin FTP command
    ... I copy your example ftp command file to a.txt saved in C:\dell folder. ... I cannot turn off Windows Firewall, since it is controlled by Domain ...
    (microsoft.public.windowsxp.general)
  • Re: FTP Setup in WIndows 2000 help
    ... Thank you for responding Bernard. ... The more I use Win2k Server the more I realize I am no IT guy... ... So FTP is still not working and now I seem to have broken forms on the ... to set up a basic login FTP service on a Windows ...
    (microsoft.public.inetserver.iis.ftp)
  • Re: ASCII text garbled on FTP download?
    ... back them up - tar them and ftp the tars to my Windows machine to ... > Or you can convert a CR to CR+LF file on windows using the following trick. ... > use knoppix to CD boot the laptop into a linux environment. ... >> files, pasting them somewhere to get the formatting back, then ...
    (comp.os.linux)