Re: How to suppress warning messages for empty lines in shell scripts?



On Sat, 31 May 2008 14:17:36 -0300, Jochen Berninger <buzzuz@xxxxxxxxxxx> wrote:

From the command line I called (with nohup) a shell script which contains empty lines
(for better readability).

The nohup executes the script successfully but outputs a warning for the empty line:

/usr/local/joch/bin/dotest: line 3:
: command not found

How can I suppress this warning (of cause without removing the empty line)?

Do I really have to always avoid empty lines in shell scripts?

Jochen


You can't use DOS style to end each line, in other words,
the line must be ended with NewLine, not "CarriageReturn+NewLine".
I think this is a possibility in your case.

See:
$ echo -e 'a \r\n\a\b\t b'|cat -A
a ^M$
^G^H^I b$
$

"\r" is a carr.ret. showed as "^M" through cat.
In your script you can test if there are CRs with:
$ cat -A yourScript

Or, if your script is large, with grep's help:
$ cat -A yourScript|grep \\^M

You can see any ^M?
If yes, this can be the problem.
Look for lines with ^..., without characters, they
are viewed possibly as empty lines in an editor.
.



Relevant Pages

  • Re: [PHP] Re: A general UL script
    ... I'm trying to validate wether or not to run the image check script. ... Posible to not add an empty field in the submit. ...
    (php.general)
  • Re: whats wrong with find -exec sed?
    ... but did the job faster than writing a script. ... But my first command still doesn't do what it is supposed to. ... files get completly empty now. ... Shouldn't there just be a switch in sed which does the trick? ...
    (alt.os.linux)
  • Re: Replace all script step - flakey?
    ... single step script with a replace statement which acts on the commish field. ... If you want records where BOTH Comm_Flag is empty AND GrandTotal is ...
    (comp.databases.filemaker)
  • Re: Enumerate Empty Global Groups
    ... Many thanks for your efforts, the script produced the exact results that I needed. ... You can use ADO to retrieve all ... > where the member attribute is empty. ... > Dim strBase, strFilter, strAttributes, strQuery, objRecordSet ...
    (microsoft.public.windows.server.scripting)
  • Re: [PHP] Re: A general UL script
    ... But that leaves me a bit off to how to tell the script to leave it alone. ... Posible to not add an empty field in the submit. ... Maby there is something else, ... stops when I check the array for actual images. ...
    (php.general)