File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Ant, Maven and Other Build Tools and the fly likes Running a shell script from ANT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Running a shell script from ANT" Watch "Running a shell script from ANT" New topic

Running a shell script from ANT

Ram Charan

Joined: Apr 07, 2004
Posts: 12
I need to run two shell scripts in sequece from ANT. The first one sets up some environment variables and the second one uses them to run IDL compiler. Here is the sequence of steps

1) When I login to unix, i will be in csh
2) The fist script should run in ksh and sets up environment variables
3) The second scripts should also run in same ksh and execute IDL compile

I do this from command line and it works.
1) When I login to Unix, I am in csh, so I just change shell by typing sh
2) I run a build.xml (using ant) that runs following.

So, I added an other exec task before the above task to change the shell using this:

But when I run the build.xml, I see that the shell has not changed. My questions are:
1) how do I change unix shells from ANT? I tried invoking a wrapper script that changes the shell and calling it from ANT but it did not work.
2) If there is a way to setup/change environment variables of Unix from ANT, I think my problem is solved.

Any help is greatly appreciated.

Ram Charan

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17416

Probably the easiest solution is to write another shell script that does all of the above and invoke it from Ant.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Running a shell script from ANT
jQuery in Action, 3rd edition