I want to call a shell script from java.I have searched in many java related web sites but I did not find the correct answer.Can anyone please help me out with this problem.
plzzzzzzzzzzzzz
thank you!!

Recommended Answers

All 2 Replies

Execute ls -l command using java.

Runtime rt = Runtime.getRuntime();
Process p = rt.exec("ls -l");
p.waitFor();

Here ls -l can be replaced with any valid Unix/Linux/DOS commands as well as Shell script/Batch Files.

not that it'll do you much good...
You're throwing away both the error and output streams :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.