You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by SHAILJA <sh...@gmail.com> on 2010/06/07 09:10:19 UTC

Re: Ant1.8 copy task gives error "Failed to copy" with "Permission denied"

Hi Stefan,

>>
/u/kumari/ant> less less build.xml 
<project> 
<target name="install_scripts"> 
 <copy file="${basedir}/myfile.txt" tofile="/u/kumari/myfile.txt"/> 
 <chmod file="/u/kumari/myfile.txt" perm="555"/> </target> 
 </project> 
>>

I tried with apache-ant-1.8.1 also and got same error as previous append.


>>
i.e. add a filterset that doesn't change your files at 
all)
>>

Can you please suggest me what kind of filter set I can use to copy and
change mode of this file.



Stefan Bodewig wrote:
> 
> On 2010-05-18, SHAILJA <sh...@gmail.com> wrote:
> 
>> Stefan Bodewig wrote:
> 
>>> Sounds like you are hitting the problem described in the recently opened
>>> <https://issues.apache.org/bugzilla/show_bug.cgi?id=49261>
> 
>> When the above mentioned bug will be fixed?
> 
> Like the bug report says, it is already fixed in trunk and will be fixed
> in the next release (after 1.8.1).  The fix may not be what you expect,
> though.  The next release will never overwrite read-only files with
> <copy> unless you explicitly set a force attribute to make it do so.
> 
> For Ant 1.8.0 and 1.8.1 there is a workaround - make <copy> use the
> filtering mode (i.e. add a filterset that doesn't change your files at
> all) and it will overwrite read-only files just like 1.7.1 did.  This
> workaround won't work anymore with the next release.
> 
> Stefan
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Ant1.8-copy-task-gives-error-%22Failed-to-copy%22-with-%22Permission-denied%22-tp28179282p28801724.html
Sent from the Ant - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: Ant1.8 copy task gives error "Failed to copy" with "Permission denied"

Posted by Stefan Bodewig <bo...@apache.org>.
On 2010-06-07, SHAILJA wrote:

> /u/kumari/ant> less less build.xml
> <project>
> <target name="install_scripts">
>  <copy file="${basedir}/myfile.txt" tofile="/u/kumari/myfile.txt"/>
>  <chmod file="/u/kumari/myfile.txt" perm="555"/> </target>
>  </project>

> I tried with apache-ant-1.8.1 also and got same error as previous append.

Yes, this is to be expected.  More so it will be that way with any later
release of Ant as well. In addition the workaround I suggested will stop
working in the future (but you get a new attribute on <copy> which makes
it overwrite read-only files).

> Stefan Bodewig wrote:

>> For Ant 1.8.0 and 1.8.1 there is a workaround - make <copy> use the
>> filtering mode (i.e. add a filterset that doesn't change your files at
>> all) and it will overwrite read-only files just like 1.7.1 did.

> Can you please suggest me what kind of filter set I can use to copy and
> change mode of this file.

Please note, filtering will break binary files so the advice only
applies to text files.  It will not change the mode of any file, it will
just make Ant fall back to the same code that was used in <copy> prior
to Ant 1.8.0 which would happily overwrite read-only files.

What I suggest is something like

  <copy file="${basedir}/myfile.txt" tofile="/u/kumari/myfile.txt">
    <filterset>
      <filter token="foo" value="bar"/>
    </filterset>
  </copy>

where I assume that myfile.txt does not contain a literal @foo@.  With
this approch replacing tokens doesn't change the content of your file
and read-only files can be overwritten in 1.8.[01].

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org