Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Reading data from a file using Ant

Reply
Thread Tools

Reading data from a file using Ant

 
 
rynox
Guest
Posts: n/a
 
      11-16-2005
Hi Everyone,

Im new to Ant and I am encountering some problems.
I have a text file which contains a value in there. I need that value
to be set into another file.
I tried using Javascript but Javascript does not support I/O for files.
Is there any command in Ant that can read a value from a text file (
eg. output.txt ) and then use that value to replace into another file (
eg. jsp ).

Thanks,
Marvin

 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      11-16-2005
On 15 Nov 2005 22:40:51 -0800, "rynox" <(E-Mail Removed)>
wrote, quoted or indirectly quoted someone who said :

>Im new to Ant and I am encountering some problems.
>I have a text file which contains a value in there. I need that value
>to be set into another file.
>I tried using Javascript but Javascript does not support I/O for files.
>Is there any command in Ant that can read a value from a text file (
>eg. output.txt ) and then use that value to replace into another file (
>eg. jsp ).


see http://mindprod.com/jgloss/multiposting.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
Reply With Quote
 
 
 
 
rynox
Guest
Posts: n/a
 
      11-17-2005
There dont seem to be any syntax that shows how i can retrieve a value.

 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      11-17-2005
On 16 Nov 2005 17:56:25 -0800, "rynox" <(E-Mail Removed)>
wrote, quoted or indirectly quoted someone who said :

>There dont seem to be any syntax that shows how i can retrieve a value.


Want you want is a way to read a small amount of text from a file and
put it into an ANT property?

Look at the LOADFILE task.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
Reply With Quote
 
littlemaster littlemaster is offline
Junior Member
Join Date: May 2009
Posts: 2
 
      05-22-2009
Hello,

This works, but I have the following situation:

I have an ant script that we use to deploy code. The user logs on with their id and then uses 'su' command to switch over to a user called ant.

At this time, I can use the "logname" command to get which user is logged on to the system. This returns the original username but not ant.

I need this userid to find out whether this user has access to deploy the code.

However when I try to run this command from an ant script, I do not get any output.

Can anyone help me figure out how to get the loginname or the result of this command through the ant script so that I can use it.

FYI here is the script that I use:

<target name="main" >

<exec executable ="/bin/sh">
<arg value = "-c" />
<arg value = "logname" />
</exec>

and here is the output that I get:

main:
[exec] logname: no login name
[exec] Result: 1

BUILD SUCCESSFUL
Total time: 0 seconds

Can someone help?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run ant script from ant script? lionelv@gmail.com Java 6 07-26-2007 02:12 AM
error runing ant in eclipse ant view yihucd@gmail.com Java 1 03-07-2006 08:39 PM
An Automated process of watching a network file folder, reading a file in it and deleting the file using ASP.NET ? Luis Esteban Valencia Muņoz ASP .Net 3 06-04-2005 10:56 AM
trouble with Hibernate and Ant (probably just Ant) john martin Java 2 04-07-2005 09:27 PM
wondering how i can launch tomcat from ant without ant hanging... Chris Bedford Java 6 12-23-2004 12:41 AM



Advertisments