3

I have a batch file and it has below command(.bat file) to execute my application. I need to move the same application to Linux environment and need to write .sh file to execute the same application. I don't have any idea of the shell scripting. Please can some one give idea to convert this to .sh file?

SET currentDir=%CD%
CD %~dp0
SET CLASSPATH=./lib/*;
java -Dlogback.configurationFile=./com/logback.xml  -cp "%CLASSPATH%";"App.jar" com.test.main.MainClient
SET ERROR_LEVEL=%ERRORLEVEL%
CD %currentDir%
EXIT /B %ERROR_LEVEL%
0

1 Answer 1

2

Since it dosn't appear to be very complex, conversion shouldn't be too dificult. Have look here for a comparison of batch and bash syntax.

You can leave your java-command almost as it is, just change the way you call CLASSPATH. And keep in mind that bash is case-sensitive.

Sign up to request clarification or add additional context in comments.

2 Comments

I have wrote the script as below.'export JAVA_HOME=/usr/jdk/instances/jdk1.8.0 export PATH=$JAVA_HOME/bin:$PATH java -version export CLASSPATH=./lib/*; java -Dlogback.configurationFile=./conf/logback.xml -cp "%CLASSPATH%":"App.jar" com.test.main.MainClient exit' it is not showing any error. But application not running as expected.
how do you call it? via bash script.sh or have you inserted #!/bin/bash as first line?

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.