On 6/24/05, Gary Feldman <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > >...I call the exec task: > > > ><exec program="osql"> > > <arg value="-E -S ${nameOfDBServer} -n -d ${nameOfDatabase} -Q < > >"${DBScriptPath}""/> > ></exec> > > > > > This isn't the right way to call it. It's equivalent to typing > > osql "-E -S $... < ..." > i.e., putting everything into quotes and passing it as the first argument
Being picky here, but the arg value won't be quoted like this, because the string already contains quotes. That said, you're right in that it's an incorrect usage of arg value=, and should instead be arg line=. > ><exec program="osql"> > ><arg value="-E" /> > > <arg value="-S ${nameOfDBServer}"/> > > <arg value="-n" /> > > <arg value="-d ${nameOfDatabase}"/> > > <arg value="-Q < "${DBScriptPath}"" /> > ></exec> > This is the right way to call it - except for the redirection in the > last arg. Still being picky, the arguments should be split up further, so "-S" and "${nameOfDBServer}" are separate arguments (unless they would normally be quoted into a single argument), or use arg line= again. > To understand this, you need to understand that redirection is a > function provided by the command line interpreter. It's not provided > (at least not directly) by the mechanism NAnt uses for actually > executing other programs. You could probably make this approach work by > having the exec invoke cmd (on Windows) or the shell of your choice (on > Mono), passing it the entire command line formatted correctly. But that > wouldn't be the cleanest way of doing it. Not the cleanest way of doing it, but it's currently the only real way to provide redirected input to a command. There's always the option of executing a batch or shell script, but that's basically the same thing wrapped in an indirection layer. > My copy of osql indicates that there's an -i option for specifying the > input file. Can you use that? That would be the easiest, cleanest way > of doing things. > > In the long run, it would make sense for NAnt to provide an attribute > input="..." for this functionality, but it's not there yet. This wouldn't be too hard to add in the trivial case, reading the contents of a file and passing as input to the command, but it's only a small part of what redirection is... much more useful would be to implement pipes, so you could chain execs, much like you can in the console. As an interim measure, it would probably be easier if the <exec> could detect the use of redirection (|<>) and prepend the command with either "cmd /c" or "sh", depending on environment... that way, people could use commands they are familiar with and get the full power of redirection using NAnt, and it would be easier to port existing scripts into NAnt in a piece-by-piece fashion. -- Troy ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click _______________________________________________ Nant-users mailing list Nant-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nant-users