* Math working on command line but not in script
@ 2003-09-23 5:45 Robert Mark Bram
2003-09-23 8:27 ` Brian Dessent
0 siblings, 1 reply; 3+ messages in thread
From: Robert Mark Bram @ 2003-09-23 5:45 UTC (permalink / raw)
To: Cygwin
Howdy All!
I have a small script called maths.sh with the following code in it:
#/usr/bin/bash
count=0
echo $count
count=$(( $count + 1 ))
echo $count
count=$(( $count + 1 ))
echo $count
count=$(( $count + 1 ))
echo $count
count=$(( $count + 1 ))
echo $count
When I run the instructions directly on the command line it works ok but
when I run the script, it fails, as you can see from the following screen
dump:
$ count=0
$ echo $count
0
$ count=$(( $count + 1 ))
$ echo $count
1
$ count=$(( $count + 1 ))
$ echo $count
2
$ count=$(( $count + 1 ))
$ echo $count
3
$ count=$(( $count + 1 ))
$ echo $count
4
$ ./math.sh
0
? 0 + 1 ?
? ? 0 + 1 ? + 1 ?
? ? ? 0 + 1 ? + 1 ? + 1 ?
? ? ? ? 0 + 1 ? + 1 ? + 1 ? + 1 ?
$
Can anyone tell me what is going wrong?
Any advice would be most appreciated!
Rob
:)
:->
:-}
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Math working on command line but not in script
2003-09-23 5:45 Math working on command line but not in script Robert Mark Bram
@ 2003-09-23 8:27 ` Brian Dessent
0 siblings, 0 replies; 3+ messages in thread
From: Brian Dessent @ 2003-09-23 8:27 UTC (permalink / raw)
To: Cygwin
Robert Mark Bram wrote:
>
> Howdy All!
>
> I have a small script called maths.sh with the following code in it:
>
> #/usr/bin/bash
The features you're trying to use are bash-specific. The above shebang
is not correct (you need a ! after the #, as in "#!/path/to/file") and
so the script is being executed not by bash but by sh which doesn't
understand the $(( foo )) syntax.
Brian
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: Math working on command line but not in script
[not found] <001301c381a6$a1155570$ce01efc3@asip>
@ 2003-09-23 8:59 ` Robert Mark Bram
0 siblings, 0 replies; 3+ messages in thread
From: Robert Mark Bram @ 2003-09-23 8:59 UTC (permalink / raw)
To: Cygwin
Howdy Alexander!
> You misspelled the first line, should be
> #!/usr/bin/bash
Well, now I feel plain silly!
Thanks for the answer!
Rob
:)
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-09-23 8:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-23 5:45 Math working on command line but not in script Robert Mark Bram
2003-09-23 8:27 ` Brian Dessent
[not found] <001301c381a6$a1155570$ce01efc3@asip>
2003-09-23 8:59 ` Robert Mark Bram
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).