Mike Leone on 24 Apr 2010 09:53:59 -0700

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Bash script problems - no "function" support?

On 04/24/2010 01:15 AM, JP Vossen wrote:
>> Date: Fri, 23 Apr 2010 14:35:30 -0400
>> From: Mike Leone <turgon@mike-leone.com>
>> So I'm trying to run the bash script JP posted the other day, and it's 
>> failing, for reasons I can't quite figure out.
>> $ bash -n snag-files.sh
>> 'nag-files.sh: line 15: syntax error near unexpected token `{
>> 'nag-files.sh: line 15: `function _file_size {
> [...]
> Short answer: somehow you are getting dash, not bash.  

Yeah, we (Brent and I) eventually figured that out. I was trying to run
the script as "sh script.sh", and since "sh" is a link to /bin/dash, I
was not getting it to work. The quick and easy fix was to run it as
"./script.sh" instead.

> I was going to accuse you of creating that with Notepad and saving or 
> copying to Linux, but I get a slightly different error when I do that:

I use Notepad++, actually, which is (supposed to) be able to save in
Unix format, and I did tell it to save that way. But .. it didn't. :-)
So I ended up fixing that by using a "tr" command (that I had to look up

> Hummmm...  Not quite the same error.  So maybe only some CRLFs?  Does a 
> 'dos2unix test.sh' help?  (you probably have to do 'aptitude install 
> tofrodos' to get dos2unix)  Else, as Brent already suggested:

Another new useful command (for me). Thanks! :-)

Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug