I am very much new to shell script and i want to create and run shell script.
I want to run my java program in two different environment which is simu and prod.
If i am running the program in the simu environment then execute SIMU_RUN else PROD_RUN.
For example i have two directory where file is placed in /data/etl-simu/in/
and /data/etl-prod/in/
and as you can see while reading the file from the directory name i can recognise whether the environment is simu or prod from SIMU_PATH
or PROD_PATH
variable.
I am not sure if it easy to write such shell script and execute it.
If i just create normal shell script and put the complete SIMU_RUN
or PROD_RUN
path in that shell script and execute it then in the respective environment then it will run fine.
But as i have two environment then i want to make this shell script flexible instead of creating two separate shell script for simu and prod
#!/bin/sh
SIMU_RUN="cd /opt/env/import/import/current; java -Dlog4j.configurationFile=/opt/import/config/logging/log4j2_Importer.xml -Djava.security.egd=file:///dev/urandom -classpath /opt/runner/lib/*:/opt/import/lib/* runner.Application --config /opt/import/config/import.simu.properties --workflow import --inputDir /data/etl-simu/in"
PROD_RUN="cd /opt/import/import/current; java -Dlog4j.configurationFile=/opt/import/config/logging/log4j2_Importer.xml -Djava.security.egd=file:///dev/urandom -classpath /opt/runner/lib/*:/opt/import/lib/* runner.Application --config /opt/import/config/import.prod.properties --workflow import --inputDir /data/etl-prod/in"
SIMU_PATH="/data/etl-simu/in"
PROD_PATH="/data/etl-prod/in"
MODE=$1
if [ "${MODE}" = SIMU_PATH ]; then
#execute SIMU_RUN
else
#execute PROD_RUN
fi
exit ${EXIT}