Problems while copying an executable file with ANT

Discussion in 'Java' started by Manish Hatwalne, Jul 26, 2004.

  1. I am trying to copy a compiled, execuatable file from one directory to
    another using ant task - copy. However, the file gets opied but its
    executable attribute "X" is stripped, so the file is no more executable. How
    can I preserve the file's "X" attribute?

    This is what I have used on my linux box -

    <copy todir="${riepath}" file="/my_source_path_here/name_of_execuatble">
    </copy>

    TIA,
    - Manish
     
    Manish Hatwalne, Jul 26, 2004
    #1
    1. Advertising

  2. Manish Hatwalne

    JavaJug Guest

    I think this is a gap in the ant tasks.
    There is a <Attrib> task that allow you to change the attributes of files, but
    don't delight too quick, as currently it works only under Windows.
    As you talk about 'X' attribute, I assume you're not under windows...

    The only solution I see for you is to execute a shell command that will change
    your file's attributes after copying it/them. Hopefully, you can do that with
    ant (<Apply> task).
    Assuming you are under linux, the command is "chmod u+x <your new file(s)>" (or
    a+x or o+x...).
    Ant task :
    <apply executable="chmod">
    <arg value="u+x"/>
    <fileset dir="<your dir (${riepath})>"/>
    </apply>
    will (hopefully, I'v not tested) make all files in you directory executable for
    the user. If you want to do it only on certain files, you can add
    includes="file1,file2,...,filen" in the <fileset>.

    Manish Hatwalne wrote:
    > I am trying to copy a compiled, execuatable file from one directory to
    > another using ant task - copy. However, the file gets opied but its
    > executable attribute "X" is stripped, so the file is no more executable. How
    > can I preserve the file's "X" attribute?
    >
    > This is what I have used on my linux box -
    >
    > <copy todir="${riepath}" file="/my_source_path_here/name_of_execuatble">
    > </copy>
    >
    > TIA,
    > - Manish
     
    JavaJug, Jul 26, 2004
    #2
    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. Eric Bresie
    Replies:
    1
    Views:
    1,752
    Ryan Stewart
    Feb 13, 2004
  2. Replies:
    15
    Views:
    491
    Dave Thompson
    Aug 21, 2006
  3. pratap
    Replies:
    20
    Views:
    761
    Flash Gordon
    Mar 7, 2007
  4. Jason Cavett
    Replies:
    8
    Views:
    623
    Sanjay
    May 16, 2007
  5. Replies:
    0
    Views:
    444
Loading...

Share This Page