Java is not able to locate shell script

I have a maven project. The java classes call a shell script. I have used context.getInitParameter like this:

String[] cmd = {context.getInitParameter("testabc"), value};

to call the shell scripts. In web.xml i have put the path as

<context-param>
        <param-name>testabc</param-name>
        <param-value>/opt/apache-tomcat-8.0.23/webapps/testMonitor/shellScript/Test.sh</param-value>
</context-param>

After deploying and executing I get the following error:

 java.io.IOException: Cannot run program "/bin/bash","Test.sh": error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
    at java.lang.Runtime.exec(Runtime.java:620)
    at java.lang.Runtime.exec(Runtime.java:485)
    at com.ca.controller.ChefController.saveSchzScript(ChefController.java:108)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)

The file is there, when I do a vi it displays the file, can someone tell me what am I missing here?


Source: unix

Leave a Reply