I was Able to Run shell Script using Cygwin in java. But Now I am getting following message.
Exception in thread "main" java.io.IOException: Cannot run program "D:/cygwin/bi
n/bash": CreateProcess error=193, %1 is not a valid Win32 application
How to avoid this exception?
Code
{
String cmd;
cmd = "D:/cygwin/bin/bash -c'/bin/ls -la'";
System.out.println("EXECING: " + cmd);
p = Runtime.getRuntime().exec(cmd);
in = p.getInputStream();
br = new BufferedReader(new InputStreamReader(in));
System.out.println("OUT:");
while ((line = br.readLine()) != null) {
System.out.println(line);
}
in = p.getErrorStream();
br = new BufferedReader(new InputStreamReader(in));
System.out.println("ERR:");
while ((line = br.readLine()) != null) {
System.out.println(line);
}
System.out.println();
}
.exeonto the end of the file name?bash.D:\cygwin\bin\bash.exe -c "/bin/ls -la"from a DOS prompt does it work?