2

I want to run the following script as:

bash ./scripts/startapp.sh

Here is the script:

#!/bin/bash
str=$HOSTNAME
PREV_IFS=$IFS
IFS=. components=(${str})
ORIGINAL_DIRECTORY=`pwd`
REP_DIRECTORY=$ORIGINAL_DIRECTORY/src/main/resources
for part in "${components[@]}"
do
  PATH=$REP_DIRECTORY/"$part"
  REP_DIRECTORY=$PATH
done
IFS=$PREV_IFS
CONFIG_PATH=$REP_DIRECTORY/application.yaml
# Below is the final command I want to run from the terminal
`SPRING_CONFIG_LOCATION=$CONFIG_PATH mvn spring-boot:run`

I am getting

mvn: command not found

Without starting the script, I can use mvn spring-boot:run without any problem.

1 Answer 1

2

Make sure you have defined:

  • M2_HOME pointing to the base directory of your Maven installation

  • PATH must include $M2_HOME/bin

In your script you're overwriting the value of PATH on every iteration. You should change it to:

PATH=$PATH:$REP_DIRECTORY/"$part"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.