[colug-432] Script basic

Rick Hornsby richardjhornsby at gmail.com
Wed May 13 14:36:24 EDT 2015


> On May 13, 2015, at 13:18, Scott Merrill <skippy at skippy.net> wrote:
> 
>> 
>> On May 13, 2015, at 2:12 PM, Steve VanSlyck <s.vanslyck at postpro.net> wrote:
>> 
>> Umpf.
>> 
>> Yes, I have seen it before, now you mention it. Seems my old windows machines always started with PATH=.;... Or at least I seem to remember it that way. Regardless, I always *assumed* the computer always looked in the current directory first.
>> 
>> Anyway, as you saw in previous email i am now getting this
>> [root at vslaw2 ~]# ./server_setup.sh
>> -bash: ./server_setup.sh: /bin/bash^M: bad interpreter: No such file or directory
>> error.
>> 
>> No idea what the ^M means. I don't see anything when looking at the file in nano and confirmed it with VI/VIM just to be sure, with same result
>> 
> 
> You’re running into one of the frustrating differences between Windows and UNIX (and Mac!) systems.
> 
> http://www.cs.toronto.edu/~krueger/csc209h/tut/line-endings.html <http://www.cs.toronto.edu/~krueger/csc209h/tut/line-endings.html>
> 
> https://en.wikipedia.org/wiki/Newline <https://en.wikipedia.org/wiki/Newline>
> 
> If you’re editing files on Windows and then transferring them over to Linux, you’ll likely keep having this problem.  There are several solutions.

Been there. Been bit by this. More than once.

CR?
LF?
CRLF?
^M what?

Fortunately, these days Mac (OS X) uses the same line endings as UNIX (0x0A - LF).  Mac did not used to do that.

> You can use a text editor that understands different line endings.  The default Windows Notepad application *does not* understand anything other than Windows line endings.

Notepad++ is a good one for Windows.

Edit > EOL Conversion > UNIX/OSX Format

Also, Sublime.  Lots of people like that.  I use Sublime on my Mac if I'm not using a full IDE or vim.

To make something clear - Scott's statement is true in the forward and the reverse.  The default Windows Notepad application will not understand your files/scripts that have UNIX line endings.  It will make everything appear on a single continuous line.  Basically - if you have anything to do with UNIX, don't use Notepad or Wordpad for anything.  (And please, for the love -- don't ever use MSWord either. That will cause more confusion, screwups, and stupid-but-subtle character conversions than one might imagine were possible.)

> You can use a tool called `dos2unix` on your Linux systems to convert Windows line endings to UNIX line endings.

Yep, if you find yourself in the situation and need a quick out (or someone else sends you a bad file) you want dos2unix.

Alternatively, you may want to edit your scripts on the UNIX box itself -- unless of course you're doing something where you're tearing the box down and re-creating it.  That would make it challenging to have your work blown away each time :)


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.colug.net/pipermail/colug-432/attachments/20150513/95e8506e/attachment-0001.html 


More information about the colug-432 mailing list