You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Praveen Shenoy <ps...@aol.com> on 2003/05/07 23:41:06 UTC

Tar and exec problem

I am using the exec task to run tar as we cannot use tar directly. 
Running tar directly, replaces all the file permissions. So, this is how 
I am using it

<target name="all" depends="copy_files">
         <exec dir="${build.root}/deploy" executable="tar" 
failonerror="true" >
             <arg line="-cvf ../sometar.tar *" />
         </exec>
         <delete dir="${build.root}/deploy" />
     </target>

It fails with

[exec] /bin/tar: *: Cannot stat: No such file or directory
[exec] /bin/tar: Error exit delayed from previous errors

It doesn't like th "*" after the tar name. If I change it to a specific 
directory instead of "*" it works fine. Is there a problem using "*"?

Praveen


Re: Tar and exec problem

Posted by Stefan Bodewig <bo...@apache.org>.
On Wed, 7 May 2003, Praveen Shenoy <ps...@aol.com> wrote:
>   <target name="all" depends="copy_files">
>              <exec dir="${build.root}/deploy/shopping" 
> executable="/bin/sh" failonerror="true" >
>              <arg line="tar -cvf ../../ship/package/fedeploy.tar *">
>              </arg>
>          </exec>

This would rather be

   <exec dir="${build.root}/deploy/shopping" 
         executable="/bin/sh" failonerror="true">
       <arg value="-c"/>
       <arg value="tar -cvf ../../ship/package/fedeploy.tar *"/>
   </exec>

You must tell the shell to execute the following stuff as command
(that's the -c) and the rest must be a single argument (that's why I
changed the line attribute to value).

BTW, you could use <apply> instead of <exec>, not use wildcards at all
and let Ant find the files for you.

  <apply executable="tar" dir="${build.root}/deploy/shopping"
         parallel="true" relative="true" failonerror="true">
     <arg value="-cvf">
     <arg file="${build.root}/ship/package/fedeploy.tar"/>
     <srcfile/>

     <fileset dir="${build.root}/deploy/shopping"
              includes="*"/>
  </apply>

should be exactly the same as the <exec> above but without using the
shell to expand the wildcard.

Stefan

Re: Tar and exec problem

Posted by Praveen Shenoy <ps...@aol.com>.
  <target name="all" depends="copy_files">
             <exec dir="${build.root}/deploy/shopping" 
executable="/bin/sh" failonerror="true" >
             <arg line="tar -cvf ../../ship/package/fedeploy.tar *">
             </arg>
         </exec>

didn't work. output below.

[exec] tar: /bin/tar: cannot execute binary file

Praveen

Conor MacNeill wrote:

 > On Thu, 8 May 2003 07:41 am, Praveen Shenoy wrote:
 > > I am using the exec task to run tar as we cannot use tar directly.
 > > Running tar directly, replaces all the file permissions. So, this is
 > how
 > > I am using it
 > >
 > > <target name="all" depends="copy_files">
 > >          <exec dir="${build.root}/deploy" executable="tar"
 > > failonerror="true" >
 > >              <arg line="-cvf ../sometar.tar *" />
 > >          </exec>
 > >          <delete dir="${build.root}/deploy" />
 > >      </target>
 > >
 > > It fails with
 > >
 > > [exec] /bin/tar: *: Cannot stat: No such file or directory
 > > [exec] /bin/tar: Error exit delayed from previous errors
 > >
 > > It doesn't like th "*" after the tar name. If I change it to a specific
 > > directory instead of "*" it works fine. Is there a problem using "*"?
 > >
 >
 > Wildcard expansion is performed by the shell. When you exec a command
 > from
 > Ant, the shell is not directly involved so no wildcard expansion is
 > performed. Instead of executing tar, you can execute /bin/sh and pass the
 > complete tar command as the args
 >
 > Conor
 >
 >
 > ---------------------------------------------------------------------
 > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
 > For additional commands, e-mail: user-help@ant.apache.org
 >



Re: Tar and exec problem

Posted by Conor MacNeill <co...@cortexebusiness.com.au>.
On Thu, 8 May 2003 07:41 am, Praveen Shenoy wrote:
> I am using the exec task to run tar as we cannot use tar directly.
> Running tar directly, replaces all the file permissions. So, this is how
> I am using it
>
> <target name="all" depends="copy_files">
>          <exec dir="${build.root}/deploy" executable="tar"
> failonerror="true" >
>              <arg line="-cvf ../sometar.tar *" />
>          </exec>
>          <delete dir="${build.root}/deploy" />
>      </target>
>
> It fails with
>
> [exec] /bin/tar: *: Cannot stat: No such file or directory
> [exec] /bin/tar: Error exit delayed from previous errors
>
> It doesn't like th "*" after the tar name. If I change it to a specific
> directory instead of "*" it works fine. Is there a problem using "*"?
>

Wildcard expansion is performed by the shell. When you exec a command from 
Ant, the shell is not directly involved so no wildcard expansion is 
performed. Instead of executing tar, you can execute /bin/sh and pass the 
complete tar command as the args

Conor


Re: Tar and exec problem

Posted by Bill Burton <bi...@progress.com>.
Hello,

Below ...

Praveen Shenoy wrote:
> I am using the exec task to run tar as we cannot use tar directly. 
> Running tar directly, replaces all the file permissions. So, this is how 
> I am using it
> 
> <target name="all" depends="copy_files">
>          <exec dir="${build.root}/deploy" executable="tar" 
> failonerror="true" >
>              <arg line="-cvf ../sometar.tar *" />
>          </exec>
>          <delete dir="${build.root}/deploy" />
>      </target>
> 
> It fails with
> 
> [exec] /bin/tar: *: Cannot stat: No such file or directory
> [exec] /bin/tar: Error exit delayed from previous errors
> 
> It doesn't like th "*" after the tar name. If I change it to a specific 
> directory instead of "*" it works fine. Is there a problem using "*"?

As Conor mentioned, * is expanded by the shell.  So use . instead to 
refer to the current directory.

-Bill