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:
Why is this?
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:
Why is this?
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.
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
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.