Reading data from a file using Ant

Discussion in 'Java' started by rynox, Nov 16, 2005.

  1. rynox

    rynox Guest

    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
     
    rynox, Nov 16, 2005
    #1
    1. Advertising

  2. rynox

    Roedy Green Guest

    On 15 Nov 2005 22:40:51 -0800, "rynox" <>
    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.
     
    Roedy Green, Nov 16, 2005
    #2
    1. Advertising

  3. rynox

    rynox Guest

    There dont seem to be any syntax that shows how i can retrieve a value.
     
    rynox, Nov 17, 2005
    #3
  4. rynox

    Roedy Green Guest

    On 16 Nov 2005 17:56:25 -0800, "rynox" <>
    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.
     
    Roedy Green, Nov 17, 2005
    #4
  5. rynox

    littlemaster

    Joined:
    May 22, 2009
    Messages:
    1
    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?
     
    littlemaster, May 22, 2009
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Bedford
    Replies:
    6
    Views:
    2,247
  2. john martin
    Replies:
    2
    Views:
    2,222
    john martin
    Apr 7, 2005
  3. Replies:
    1
    Views:
    513
    Larry
    Mar 7, 2006
  4. Replies:
    6
    Views:
    881
  5. Replies:
    5
    Views:
    86
    Chris Angelico
    May 14, 2014
Loading...

Share This Page