SPUG:DOS textfiles and perl on unix
Marc S. Gibian
marc.gibian at acm.org
Thu Mar 6 23:00:54 CST 2003
The apparently is a bug in sysread & syswrite that causes net::ftp to
fail to properly convert end-of-line when moving files between Windows
and non-Windows platforms. I've been trying to figure out why that has
not been working and today someone submitted it as a bug against Perl.
There is a workaround, changing the relevant line in net::ftp from
sysread to read and syswrite to write.
Hope this helps others,
From: spug-list-admin at mail.pm.org [mailto:spug-list-admin at mail.pm.org]
On Behalf Of Brian Hatch
Sent: Thursday, March 06, 2003 2:41 PM
To: Jeremy Mates; spug-list at pm.org
Subject: Re: SPUG:DOS textfiles and perl on unix
> DOS textfiles cause problems for unix, which tries to invoke
> /usr/bin/perl^M and subsequently fails with a helpful message.
> ln -s /usr/bin/perl `echo -e "/usr/bin/perl\r"`
> Actually lets the script run, in my limited testing with perl
> 5.8 on Mac OS X. Another option would be to create a perl^M
> that issues a warning.
> echo "error: $1 uses DOS linebreaks" >&2
> exit 1
You could also save the file without any DOS \r's at the end of
the line. If you're FTPing, make sure you use ASCII mode. If you
use SFTP (ftp-like over SSH) then there is no such beast, however
you can fix it once it's uploaded:
$ cd /path/to/my/perl/script
$ perl -pei.bak "s#\r#\n#g" my_perl_script
then my_perl_script won't have those annoying \r's and will run just
fine. I had to create a cron job that did this in a CGI directory for
a client that constantly uploaded them from a DOS machine.
Rather than hacking around to let a broken program work, fix the
Brian Hatch "It will be fun. Assuming you are not
Systems and vaporised, dissected, or otherwise
Security Engineer killed in an assortment of supremely
http://www.ifokr.org/bri/ horrible and painful ways.
*Exciting*, isn't it?"
Every message PGP signed
More information about the spug-list