Girardelli, Erin E wrote:
> Hi,
>
> When I try to use a pipe or redirecting arrow in the exec task, I get a
> failure saying the program I executed has the wrong number of arguments.
> Here's what it looks like within my script:
>
>       <exec program="p4.exe" commandline="label -o DevTemplate | sed
> -e "s/DevTemplate/dev01/g" | p4.exe label -i" />
>   
To understand this, you first need to understand that pipes and 
redirection are not implemented by the operating system.  They're 
implemented by a command shell, such as bash or ksh on UNIX or Linux and 
the cmd shell or Cygwin/GNU bash on Microsoft Windows.  No matter which 
shell it is, the shell is responsible for the initial parsing of the 
command line, breaking it up into simple commands and arguments, 
creating the pipes and connecting the pipes or file redirections to the 
inputs or outputs of the respective subprocesses, which it also creates.

The NAnt <exec> task doesn't do this.  It doesn't process the command 
line and it only creates a single process.  That's the reason you need 
to specify the program separately from the command line (to save NAnt 
the job of parsing it).  It's also the reason why it's better to specify 
arguments individually instead of using the commandline= attribute. 

If you're used to using pipes and tools such as sed, and you're not 
working on Mono, I encourage you to install Cygwin and use bash.  But 
whether you use bash or cmd, you pass it as the program attribute to the 
<exec> task, and either put the command line into a script as suggested, 
or, at least for bash, just pass the command line as the -c option to bash.

Gary



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to