0

I'm creating a script like this

#!/bin/csh

set h=1;

while [h=1] do  echo "hi"; h=2; done;

but when I execute it a get this:

===> message after : csh test.sh     [h=1]: No match. 
tkanzakic
  • 5,499
  • 16
  • 34
  • 41
Os M Torvalds
  • 21
  • 1
  • 2
  • 5

1 Answers1

1

Try:

set h = 1

while ( $h == 1 )
  echo "hi"
  set h = 2
end

You seem to be trying to mix Bourne shell syntax into your C shell script.

Csh is generally a lousy language for scripting, try to avoid it if at all possible

http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/

UPDATE:

The csh equivalent to read h is:

set h = $<
Barmar
  • 741,623
  • 53
  • 500
  • 612
  • #!/bin/csh set h = 1; while ( $h == 1 ) echo "hi" read h; echo "write value deferent then 1" read h end – Os M Torvalds Dec 19 '12 at 09:50
  • Don't try to put code in comments, all the formatting is lost. Edit your question. But the answer is that there's no `read` command in csh, that's Bourne shell as well. Please RTFM. – Barmar Dec 19 '12 at 09:52
  • OK Thank you again , But there is allwayse an other probleme : look to all my script – Os M Torvalds Dec 19 '12 at 10:10
  • The syntax to redirect stdout and stderr is `>&filename`, not `&>filename`. Why are you trying to write a script in csh if you have no idea what the syntax is? Please RTFM!!!!!!! – Barmar Dec 19 '12 at 10:28
  • If I answered the original question, please accept my answer. If you have new problems, start a new question, don't put them in comments. – Barmar Dec 19 '12 at 10:29
  • ok i will open new tab Question ? All your answers work correctly – Os M Torvalds Dec 19 '12 at 10:58
  • `$?` is Bourne shell, the csh equivalent is `$status`. It seems like you know Bourne shell, why are you trying to write csh scripts like that? Do you understand that these are __very__ different? – Barmar Dec 19 '12 at 11:00
  • yes i know but ;-) so sorry for this Q? , i need to convert my code to Csh fastly as possible but aftre i will read all the defferents betwin them i meen sh and csh . thank you a gain , i have creat a new tab Q : here pls take tour : – Os M Torvalds Dec 19 '12 at 11:23