Re: [SLUG] Bash Script

From: Bob Stia (rnr@sanctum.com)
Date: Mon May 30 2005 - 02:03:07 EDT


On Sunday 29 May 2005 02:18, Paul M Foster wrote:
> On Sat, May 28, 2005 at 10:31:20PM -0400, Bob Stia wrote:
> > On Wednesday 25 May 2005 21:27, Eben King wrote:
> > > On Wed, 25 May 2005, Bob Stia wrote:
>
> <snip>
>
> > I put a set -x above and a set +x below and this is what i got:
> > ----------------------------------------------------------------
> > Running /home/bob/commands/ImageMagickConvert
> >
> > /home/bob/commands/ImageMagickConvert: line 34:  
> >
> > : command not found
> >
> > /home/bob/commands/ImageMagickConvert: line 35:  
> >
> > : command not found
> >
> > /home/bob/commands/ImageMagickConvert: line 36:  
> >
> > : command not found
> >
> > /home/bob/commands/ImageMagickConvert: line 37:  
> >
> > : command not found
>
> Bob:
>
> There's a really serious anomaly here. As you run this, you're a
> "command not found" error on lines 34 through 37. But here's the
> problem: if you count down, some of those lines contain nothing, so
> there's no reason you should be getting that error. Moreover, if the
> error was occurring on lines where there's actual code, you shouldn't
> get that error but a different one. And the set +x would give you a
>
> some_command: command not found
>
> rather than just
>
> : command not found
>
> I just ran a test on something. Check to see if this file was created
> under DOS or Windows. Better, find a hex editor or something that
> will look at the file in hex. Actually the "less" command should do
> this. Just type:
>
> less /home/bob/commands/ImageMagickConvert
>
> or whatever the name of the script is. If you see some stuff in there
> that looks like this:
>
> ^M
>
> then the file was created under DOS and will not run properly under
> Linux. In fact, you may well get exactly the error you're getting.
> The reason is this: under DOS, a line termination is carriage return
> and then linefeed. Under Mac, a line termination is just a carriage
> return. Under Linux and Unix, it's just a linefeed. When Linux/Unix
> sees a carriage return in certain places in a script, it gets
> confused. I won't explain why unless you just want to know. Suffice
> it to say, it's a problem.
>
> Do what I said above and let us know if the file contains those ^M
> (carriage return) characters.
>
> Paul

Paul,

Ran the "less" command. There is nothing of which you speak. FYI I got
the script from the SuSE list. I am positive it was created in Linux.

Have a thought. I copied the script from the email message and then
modified it using Kwrite. During that process I added line feeds etc.
and deleted lines and seemingly unimportant spaces. I would think that
a text editor like Kwrite would add the proper LF and nothing else.

Question is: Is it critical for the amount of spaces/ tabs before or
after a line remain exactly as in the original ?? I notice that in most
scripts the first character in subsequent lines are spaced back from
the actual start of the line.

Maybe I should just create the script by hand using the original as a
guide rather than taking the original and simply modifying it.

Bob S.

PS Stick with me Paul & Eben. I want to solve this.

-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS). Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 19:28:25 EDT