2

I want to run the pvm2raw utility of this app from the Volume Library.

I get the following error, when typing csh build.sh tools on my Ubuntu 10.10 terminal:

enter image description here

Why is this?

andandandand
  • 21,946
  • 60
  • 170
  • 271

4 Answers4

3

Do you have instructions to launch a .sh file with csh?

While it is not necessary to name a csh script with .csh, .sh files usually imply Bourne or bash shell scripts.

Also your scrip name implies a build process. Builds are typically done with the default shell, either Bourne (sh) on old unix systems like Solaris, AIX, HP and others, and bash for Linux.

You should be able to just run build.sh without any shell preceding it (unless you have written the script yourself or have been given instructions to do so).

All that Jonathan Leffler says is true. I would add that csh does allow for empty variables with the 'notation' $?varName , which can be used like

if ( ! $?HOSTNAME ) then
    setenv HOSTNAME `hostname`
endif

So, did you write the build.sh or are you using a provided script?

If you've written your own csh script, use the block of code to check and provide default values for all of your variables. (There are other ways to achieve this, like source $HOME/.env_file, where you have to make a $HOME/.env_file that lists all of the variable assignments your script needs).

If you're using a provided script, on Ubuntu is is highly like that it is really a bash script. Look at the first line of that script, does it say #!/bin/bash (or similar), if yes, confirm script is set to execute, ls -l build.sh, you need to see something like -rwxr-xr-x at the front of the line, the 'x's being the key bit. If not then chmod 755 build.sh will solve that. Once permissions allow execution, just run ./build.sh.

I hope this helps.

shellter
  • 36,525
  • 7
  • 83
  • 90
2

HOSTTYPE is a non-POSIX Bash extension

It is documented in man bash, and we can confirm that POSIX does not mention it by downloading and grepping: Is there a listing of the POSIX API / functions?

Therefore, it is not surprising that the variable is not defined in csh, which gives an error.

See also: Detect the OS from a Bash script

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
2

The C Shell doesn't like you to refer to undefined variables. So, you need to set $HOSTTYPE before running the script, or fix the script so that it determines $HOSTTYPE correctly for itself.

The Bourne shell and derivatives treat an undefined variable as an empty string most of the time.

Suggestion: don't use the C Shell for programming. See: Csh Programming Considered Harmful.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
0

I too faced similar problem.

Try:: tcsh build.sh

Vaidya
  • 1