Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Hi Ovid,

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:

ln -s /usr/bin/perl "/usr/bin/perl$(echo -e "\r")"

Or in 'set -o vi' mode in bash or Korn shell they could have just typed this:

ln -s /usr/bin/perl /usr/bin/perl^V^M
(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:
$ ls /bin/bash* | cat -v /bin/bash /bin/bash^M $ file /bin/bash^M : ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Li +nux 2.0.30, dynamically linked (uses shared libs), for GNU/Linux 2.0. +30, stripped $ /bin/bash^M Your shell script has DOS linefeeds in it!

You could do the same thing with /usr/bin/perl^M

If my users were the kind who wouldn't know what that meant I would probably add some extra hints, like:
Your Perl script has DOS linefeeds in it! If you uploaded it to the server via FTP please upload it again in ASC +II mode.
For users with shell access I would probably add a message about dos2ux or saving it after doing:
set ff=unix
in vim or doing:
:%s/^V^M//g
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.


In reply to Re: (OT) Fixing Line Endings by serf
in thread (OT) Fixing Line Endings by Ovid

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (14)
    As of 2014-07-23 19:38 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (152 votes), past polls