I'm running below code on windows using java and want to run same code on CENT OS machine using java but not getting any fruitful. Please let me know what changes are required to solve this issue.
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
public class CommandPrompt {
public static void main(String[] argv) throws Exception {
try {
Process child = Runtime.getRuntime().exec(commands);
child = Runtime.getRuntime().exec("cmd /c \"\" aws cp E:\\rock.jpg s3://bucket");
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(child.getOutputStream()));
InputStream in = child.getInputStream();
int c;
while ((c = in.read()) != -1) {
System.out.print((char) c);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
in.close();
}
}
}
Now I want run above code on cent os (unix) but not getting any fruitful.
cmdthing only works with Windows/DOS .