|Do you know where your variables are?|
Re: (OT) Fixing Line Endingsby serf (Chaplain)
|on Dec 01, 2006 at 09:40 UTC||Need Help??|
Good question! :o)
I agree with your response to rhesa's suggestion too - when the kind of user who is going to send a file in binary mode is in a stressed state trying to figure out why the Perl isn't where it's meant to be (because that's what they'll be thinking when they see the error) often the last thing they're going to think about is the fact that they may or may not have been told that they should transfer their files in ASCII mode - which might not have meant anything to them at the time they were told it.
You either need to stop these problems from happening, or alternatively have something there and then to tell them the cause of their problem so they can quickly fix it themselves.
Not teaching you to suck eggs, the rest of this post is for anyone else reading this looking for answers to the same kind of problem:
For generating the link, from the command line in bash the original person could have just done this:
Or in 'set -o vi' mode in bash or Korn shell they could have just typed this:
(For those that don't know, ^V^M is typed [Ctrl+V][Ctrl+M])
Another solution I used when I used to host shell accounts for my friends on my Internet server (to help them learn how to use Linux) and was getting fed up with having to regularly look at their scripts for them to tell them why they would not run... was to compile a little C program which just generated a warning message telling them what was wrong, and install that as /bin/bash^M on my system so that the user would understand the problem and fix it themselves.This is on my old machine:
You could do the same thing with /usr/bin/perl^MIf my users were the kind who wouldn't know what that meant I would probably add some extra hints, like:
For users with shell access I would probably add a message about dos2ux or saving it after doing:
in vim or doing:
and saving it...
But I expect the majority of people running Perl scripts that have been sent from a CRLF machine probably have FTP/web access only.
If anybody reading this is thinking about just copying /usr/bin/perl to /usr/bin/perl^M for any reason - don't do it, use the symlink instead.
If you just copy the file, when you upgrade perl you will be left with an orphaned copy of the old version unless you (and whoever comes after you in supporting the machine) always remembers to upgrade that file too = not clever.