From: Melvin on
Hi,

I was trying to code a simple while loop in tcsh shell.

#!/bin/tcsh
set cnt=5
while ($cnt > 0)
cnt = $cnt(`expr($cnt - 1))
end

However I am getting the following error :
cnt=4: command not found (Error is going on till <ctrl+c> is pressed.

Is this an error with the syntax?

Thanks
Unix baby

From: Bit Twister on
On Thu, 21 Jan 2010 22:48:52 -0800 (PST), Melvin wrote:
> Hi,
>
> I was trying to code a simple while loop in tcsh shell.
>
> #!/bin/tcsh
> set cnt=5
> while ($cnt > 0)
> cnt = $cnt(`expr($cnt - 1))
> end
>
> However I am getting the following error :
> cnt=4: command not found (Error is going on till <ctrl+c> is pressed.
>
> Is this an error with the syntax?

Yes.

> cnt = $cnt(`expr($cnt - 1))
^ ^
| |
You have-----' and missing--'
From: Sidney Lambe on
On comp.unix.shell, Melvin <whereismelvin(a)gmail.com> wrote:
> Hi,
>
> I was trying to code a simple while loop in tcsh shell.
>

Anyone trying to learn to script in a c-shell would have to
be doing simple things, because they are obviously simple.

Try opening your eyes. Almost everyone in the world is
using a POSIX shell, usually bash.

This has got to be a braindead troll jerking the group around.
This sort of stupid, childish game makes them feel superior.

Killfiled.


Sid


From: Rakesh Sharma on
On Jan 22, 11:48 am, Melvin <whereismel...(a)gmail.com> wrote:
> Hi,
>
>   I was trying to code a simple while loop in tcsh shell.
>
> #!/bin/tcsh
> set cnt=5
> while ($cnt > 0)
> cnt = $cnt(`expr($cnt - 1))
> end
>
> However I am getting the following error :
> cnt=4: command not found  (Error is going on till <ctrl+c> is pressed..
>
> Is this an error with the syntax?
>
> Thanks
> Unix baby

For math operations we have the @ operator in the c-shell & it's ilk,
like so:

#!/bin/tcsh -f
@ cnt = 5
while ( $cnt > 0 )
echo $cnt
@ cnt--
end


-- Rakesh
From: Barry Margolin on
In article
<041cb750-67fb-478e-91de-1ca043e5bca9(a)a32g2000yqm.googlegroups.com>,
Melvin <whereismelvin(a)gmail.com> wrote:

> Hi,
>
> I was trying to code a simple while loop in tcsh shell.
>
> #!/bin/tcsh
> set cnt=5
> while ($cnt > 0)
> cnt = $cnt(`expr($cnt - 1))
> end
>
> However I am getting the following error :
> cnt=4: command not found (Error is going on till <ctrl+c> is pressed.
>
> Is this an error with the syntax?

You left out the command "set" in the assignment inside the loop.

--
Barry Margolin, barmar(a)alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***