Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I don't have any experience writing .sh files. I want to run the pvm2raw utility of this app from the Volume Library.

I get the following error when running in Ubuntu 10.10.

enter image description here is as follows:

# make command
set mmfile=V3Makefile
set make="make -f $mmfile"

set rule=$1
if ($rule == "") set rule="all" // line 16

if ($rule == "deps") then
   if ($HOSTTYPE == "i386") $make MAKEDEPEND="c++ -M -I/usr/X11R6/include" OPTS="-DHAVE_CONFIG_H -DVIEWER_HAVE_DCMTK" TARGET=LINUX depend

What's wrong there?

Edit: I followed jw013's advice and installed csh. Now I get the following error:

enter image description here

How can I solve this Undefined variable problem?

share|improve this question
Slightly off-topic, but eww, a csh script? It seems so ... primeval. –  jw013 Feb 11 '12 at 5:08
A csh script named Double eww. –  Keith Thompson Feb 11 '12 at 23:41
You must have run it as sh ./ If you had run it as ./, you would have gotten a different error message. –  Keith Thompson Feb 11 '12 at 23:49
i'm curious why you posted screenshots of your terminal rather than simply copying and pasting. –  ixtmixilix Feb 12 '12 at 0:57
Text is always preferred over images, in regards to stdout/stderr. Text can be indexed. –  TechZilla Feb 12 '12 at 21:35

1 Answer 1

The script is declared as

#!/bin/csh -f

The syntax also matches that of csh. You are running it as


Since csh is compatible with neither Bourne nor POSIX sh, the mismatch causes lots of syntax errors. The correct way to run is either


or by making it executable (chmod +x and running it directly, letting the system choose the correct interpreter according to the shebang (#!) line:


(assuming it's in your current directory).

The HOSTTYPE variable is only defined in tcsh, which is one of the csh implementations. If csh is some other csh implementation on your machine, make sure that you install tcsh, and run


or change the first line of the script to #!/bin/tcsh -f.

share|improve this answer
Thanks; I installed csh via apt-get, but got this:csh HOSTTYPE: Undefined variable. Any ideas? –  andandandand Feb 11 '12 at 6:18
HOSTTYPE is automatically set by most shells. I'm not sure why it is not set for you - maybe you could make a new question for this. Post your shell version and relevant details about your environment. –  jw013 Feb 11 '12 at 6:44
@omgzor There are two implementations of csh: the original C shell by Bill Joy, and the more recent and more featureful tcsh. Only tcsh defines HOSTTYPE (​@jw013: and bash, following tcsh). This script assumes that /bin/csh is the tcsh implementation. –  Gilles Feb 11 '12 at 23:34
The #!/bin/csh -f isn't in the snippet that the OP posted, but it is in the script for the app. I was going to mention that is a poor name for a csh script, but that's the fault of the app developer, not of the original poster. –  Keith Thompson Feb 11 '12 at 23:41
@Gilles Thanks for the comment and edit. –  jw013 Feb 12 '12 at 0:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.