bash Scripts

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Lynn David Newton
Date:  
Subject: bash Scripts
Ummm ... I respectfully beg to differ on these scripts.
There is nothing wrong with them

>> #!/bin/bash
>> for i in `seq 1 10`;


jay> Try removing the ";" on this one. You already
jay> have a CRLF because the "do" statement is on
jay> another line.


This is true, but the semicolon won't prevent it from
running. In fact, it runs quite well.

>> With the "while" and "until" scripts when they are run I get a ">" and it
>> just sets there until I do a ctrl-c. The scripts are as follows:
>>
>> #!/bin/bash
>> COUNTER=0
>> while [ $COUNTER -lt 10 ]; do
>> echo The counter is $COUNTER
>> let COUNTER=COUNTER+1
>> done


jay> There are a few errors in this one. Here is an
jay> example that works:


A few errors? I don't think there are any at all. It
works fine as is. So does this one:

>> #!/bin/bash
>> COUNTER=20
>> until [ $COUNTER -lt 10 ]; do
>> echo COUNTER $COUNTER
>> let COUNTER-=1
>> done


The problem must lie elsewhere. I have two wild
guesses.

Clayton --

o What are you using for an editor? I suspect the
presence of invisible characters.

o Is the #!/bin/bash (so-called shebang) string the
*absolutely first* thing in the file, with no
indentation, blank lines or stuff like that?

Even if it's not, if you're running bash as a login
shell, it would still run. (But the shebang *should*
be present and correct on general principles.)

o Are you using some tool like MS Word to create the
script? The file must contain no other characters
than the ones you see visible, and there should be
real characters at the end of each line.

As I said, the scripts work fine as you posted them, or
at least as they wind up in email, so there is
something funny going on behind the scenes.

--
Lynn