Windows Batch to Bash

This line is called in a windows batch file and I need to call the same 3 jars with Parms in a bash script.

cd "D:\ACDRIP\JARS"
java -cp ".\RIPError.jar;.\RIP31.jar;.\RIP31msg_en_US.jar" ResubmitErrors -Ahost -P185050
pause

Any ideas how to do this in Bash?

What have you tried so far? Note some changes, if you are running on WSL (like ubuntu for windows 10):

backslashes '\' have to be forward slashes '/'

The environment variables have to be set in bash so that java runtime libraries (correct one(s)) are in the right environment variables, and java itself is in the PATH variable.

Other than that the only "pause" call in UNIX is from C, not bash, and its semantics are not the same. So you will have to emulate pause, i.e., write a bash function called pause()

add a #!/bin/sh at line 1

D: must be a valid *nix path like /java

sed -i 's/\\/\//g'  <script>

will do the rest.

then you will have something like:

#!/bin/sh
cd "/java/JARS" 
java -cp "./RIPError.jar;./RIP31.jar;./RIP31msg_en_US.jar" ResubmitErrors -Ahost -P185050 
read

don'f forget the

chmod +x <script>

In addition to what dodona already said: avoid relative pathes in scripts! Sooner or later (and always at the least convenient moment) they tend to bite your behind. I would change the above to:

#!/bin/sh
fAppRoot="/java/JARS"

cd "$fAppRoot"       # maybe not necessary any more
java -cp "$fAppRoot/RIPError.jar;$fAppRoot/RIP31.jar;$fAppRoot/RIP31msg_en_US.jar" ResubmitErrors -Ahost -P185050 
read

I hope this helps.

bakunin

1 Like