aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes Ant - Execute commands inside another EXEC environment 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 "Ant - Execute commands inside another EXEC environment " Watch "Ant - Execute commands inside another EXEC environment " New topic
Author

Ant - Execute commands inside another EXEC environment

Ad Pasha
Greenhorn

Joined: Mar 17, 2014
Posts: 3
ANT: My exec target starts a process, and expects further commands from user at the command prompt. Think of it as starting a server. After it's started, I need to provide further commands to this process such as unpack, deploy, stop, start etc... Could someone please show me an example of how this is typically done in ANT? To make it even more challenging, the process may ask for user inputs.

The set of commands below shows what I am trying to automate:

Unix-Prompt> myProcess
==== Welcome to myProcess ===
> unpack myJar.zip
This will overwrite your current install. Are you sure (y/n)?
y
> deploy myApplication
> stop server
Are you sure (y/n)?
y
> start server
> quit
=== Good Bye ===
Unix-Prompt>
Roger Sterling
Ranch Hand

Joined: Apr 06, 2012
Posts: 426

I'm not sure what you are asking, as the documentation is fairly specific about how to redirect stdin or stdout.

Is there something in the documentation that is confusing for you ?

I/O redirection wrote: input A file from which the executed command's standard input is taken. This attribute is mutually exclusive with the inputstring attribute.
Ad Pasha
Greenhorn

Joined: Mar 17, 2014
Posts: 3
Do you mean that the code below will have the same effect as running the unpack, start, stop... commands within the "myProcess" runtime?


where, in.txt has:


Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5845
    
    7

Yes, that it correct. You can verify this with a simple Java app that gets input from stdin and echos that input.


JBoss In Action
Ad Pasha
Greenhorn

Joined: Mar 17, 2014
Posts: 3
Unfortunately, the "Are you sure?" prompts are difficult to answer / bypass. The "y"s in the in.txt are interpreted as separate commands, rather than inputs to the prompts. The in.txt approach helps me execute multiple commands in exec (in my case, sshexec), but doesn't help with the prompts
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ant - Execute commands inside another EXEC environment