Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

execute shell script with cygwin

807591Apr 24 2008 — edited Apr 25 2008
Hi,

I'v been reading this posting [http://forum.java.sun.com/thread.jspa?forumID=31&threadID=699276] about how to achieve running a bash script from a java application, but I didn't get it working. Currently my code is
@Action(block = Task.BlockingScope.ACTION)
public void executeTestGenerator() {
	File workDir = new File("c:/cygwin/bin");
        String[] cmdArray = new String[5];
        
	cmdArray[0] = "c:/cygwin/bin/bash";
        cmdArray[1] = "--login";
        cmdArray[2] = "-i";
        cmdArray[3] = "-c";
        cmdArray[4] = "/cygdrive/c/temp/dwhim";
		      
	try {
		Runtime.getRuntime().exec(cmdArray, null, workDir);
		System.out.println("Executing cmd");
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
But nothing happens when I invoke this method. Has anybody an idea how to get this working?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 23 2008
Added on Apr 24 2008
2 comments
322 views