Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

How to EXEC each line in a file?  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to exec "some-executable" for each line in an input file using the
input line as a parm to the executable. I understand how to use the exec task and how to pass the parm. What I need to know is how to iterate through the exec task for each line of the file? The file contains 1-n lines.
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Rob Wunderlich:
I want to exec "some-executable" for each line in an input file using the
input line as a parm to the executable. I understand how to use the exec task and how to pass the parm. What I need to know is how to iterate through the exec task for each line of the file? The file contains 1-n lines.



I think you need to add some more details, but are you saying that you have the EXEC task executing a script and each time you execute that script you want to use a given line in your file as input to that script? Or is each line in that file a different script you want to run? More details are needed.

If you are trying to pass different parameters to the script each time it is executed then I suggest you write a shell script to do this for you, rather than hacking it with ant.

So you wuld have 3 files total:
1) The file that contains a list of arguments for each line
2) The script that uses these arguments as input
3) A script that iterates through the 1st file, executes the 2nd file passing it the arguments given in the 1st file

Finally your ant script would use the EXEC command to execute the 3rd file (aka the shell script).
 
Ryan Zezeski
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Option B would be to write your own Java class that does this and extend ant with your own taskdef.


I'm sure there is a way to hack it in ant, but it would be just that, an ugly hack. Either that or i'm not fully aware of the capabilities of ant.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!