Of CGI Scripts and Line Endings

MJ Ray said in Bad Tech: CGI Scripts and Line Endings:

Problem: CGI scripts uploaded with the MS Windows version of FileZilla over SFTP don't work until converted. Either there's some FileZilla settings wrong by default, or it just doesn't work.

The problem is that unlike with traditional FTP, which in ASCII mode would automagically translate line endings in to a sane format, SFTP (as far as I can tell) will always send them as binary, and thus if they were in DOS format before the transfer, they'll be in DOS format after the transfer. So, your choices are (other than the evil perl^M symlink)...

Teach users about line endings - get them to do the equivalent of a :set fileformat=unix in vim before saving ;) (I'm not sure which editors out there let you set what line endings to use - might be worth finding out what the users use and looking it up)

When they upload, rather than them uploading directly in to FTP space it hits an area that is checked every x minutes - that area is then copied to the right area with the transformation being done server side

Something else.

Posted: 2007-03-03 09:52 in Tech | permalink