Line endings difference Windows <-> Linux

Christofer C. Bell christofer.c.bell at gmail.com
Mon Jun 10 20:38:08 UTC 2013


On Mon, Jun 10, 2013 at 2:24 PM, Bo Berglund <bo.berglund at gmail.com> wrote:

> On Mon, 10 Jun 2013 13:50:00 -0500, "Christofer C. Bell"
> <christofer.c.bell at gmail.com> wrote:
>
> >On Mon, Jun 10, 2013 at 1:38 PM, Bo Berglund <bo.berglund at gmail.com>
> wrote:
> >
> >>
> >> So here is my simple question:
> >> Has Apache/PHP/MySql been adapted to accept all line ending systems
> >> around without breaking like in the old days?
> >> If that is so then I can stop worrying about line endings in the
> >> future. :-)
> >
> >
> >
> >I can't answer your question, but I can say you might consider installing
> >the package dos2unix.  It includes the commands dos2unix and unix2dos for
> >converting the line endings in ascii files automatically.  I won't convert
> >what doesn't need converting, either.  So you can run "dos2unix" twice on
> >the same file and still have the Unix format file.  You can run it in
> >binaries (images, programs) and it won't corrupt them.
> >
> >Convert your entire website at once:
> >
> >$ find /var/www | xargs -r dos2unix
> >
> >I hope this helps!
>
> Well, things are a bit complex.
> I check out the files from CVS to my Windows7 machine and I commit
> back when they are edited. On Windows this requires them to be using
> CRLF line endings.
> I have also used an Apache server on my Win7 PC to check the site
> before sending to the real server. This worked fine until I had to
> start doing MySql stuff too. Much too complex to install in Win7...
>
> So I created an Ubuntu test machine (VMWare virtualization) and got
> the needed website stuff:
> apt-get install lamp-server^
> was all I needed to do! :-)
>
> Over the weekend I have also struggled to make rsync over ssh work and
> I finally succeeded, so when I have edited the site files in Windows I
> can just launch a batch file with my rsync commands to update the
> website on ubuntu with the changed files.
> Then I can test it.
>
> But it is not possible to do rsync to the web hosting company so I am
> limited to FTP or sFTP, and here is where I saw the line ending
> "problem".
>
> If it is not a problem then fine, otherwise I will have to be vary
> careful every time I update the public server....
>

>From which system do you publish to the hosted server?  You can "correct"
the files with find and dos2unix there and then push them out, or you can
convert them on the hosted server if you're able to install dos2unix on
it.  The problem doesn't seem to be anywhere else in your workflow other
than "once it hits production".  So the files only need to be corrected
either immediately prior to deployment or immediately after deployment.

If immediately prior:

workstation:~$ find staging/ | xargs -r dos2unix
workstation:~$ deploy staging/ # where "deploy" is a placeholder for
whatever you use

If immediately after:

server:~$ find production/ | xargs -r dos2unix

Or have a periodic cronjob that runs it every few minutes (I'm not sure how
many files we're talking about).  If you find that everything is working on
your testing VM already anyway, then all of this is moot.  What works in
your Ubuntu VM will undoubtedly work in production, as long as you are
deploying from your test environment (i.e.; the actual code you test is
what is copied to production).

-- 
Chris

"If you wish to make an apple pie from scratch, you must first invent the
Universe." -- Carl Sagan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20130610/a2a5f863/attachment.html>


More information about the ubuntu-users mailing list