I am Executing Shell scripts in Java Using Cygwin. My Scripts are running fine at command prompt, and even if I try simple shell scripts through Java it works fine.
But now my scripts are using another shell scripts from the folder called lib So I need to include lib folder into my project.
Can any one suggest the way how to include shell script as a part of Java project.
Lib Folder-->
InSide Lib Folder these are the Shell scripts. Which my_script.sh is using.
Edit:- I want to add Shell script inside my project which uses Command line arguments and some other scripts from above folder structure.
cmd = "D:/cygwin/bin/bash -c '/bin/my_script.sh 121 121 1212 12121'";
Help me for Doing this.
Shell Scripting is an open-source operating system. Our Shell Scripting tutorial includes all topics of Scripting executing scripting, loops, scripting parameters, shift through parameters, sourcing, getopts, case, eval, let etc.
If you are using maven as a build tool the best solution is to add scripts under /src/main/resources
. In this case the scripts will be automatically included into your jar file, so you will be able to extract them on the fly from your java code and run.
If you want to have the scripts separately you suggested good solution. I mean lib
folder. But again since I am using maven I'd put them under /src/main/sh
(exactly as I put my java files under /src/main/java
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With