"source" command in shell script not working [duplicate] "source" command in shell script not working [duplicate] shell shell

"source" command in shell script not working [duplicate]


source is a command implemented in bash, but not in sh.There are multiple ways to fix your script. Choose either one.

Run the script using bash interpreter

When you are invoking the xRUN script - you are explicitly telling it to be interpreted by sh

$ sh xRUN 

To change and interpret the script with bash instead do

$ bash xRUN 

This will make bash interpret the source command, and your script will work.

Use dot command to make script bourne compatible

You can also change the source with a dot command which does the same thing but is supported in both bourne and bash.

Change the line:

source set_puregev_env

With:

. set_puregev_env 

Now the script will work with either sh or bash.

Make script executable

You should also run the script directly to avoid confusions like these by making it executable chmod +x xRUN, and invoking it like this:

$ ./xRUN

It will then use the command specified in the shebang and use the rest of the script as input. In your case it will use bash - since that is specified in the shebang.