ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dick, Brian E." <Brian.D...@FMR.com>
Subject RE: Problems with exec task
Date Tue, 31 Jan 2006 16:29:41 GMT
-- hello there.vbs
strArg   = ""
strDelim = ""

for each objItem in WScript.Arguments
   strArg   = strArg & strDelim & objItem
   strDelim = " "
next

WScript.echo "hello there, " & strArg

-- cscript.xml
<project name="cscript" default="hello">

   <target name="hello">
      <exec taskname="cscript"
            executable="cscript.exe"
      >
         <arg file="hello there.vbs"/>
         <arg value="//Nologo"/>

         <arg value="Rhino"/>
      </exec>
   </target>

</project>

-- example run
C:\temp\ant -f cscript.xml
Buildfile: cscript.xml

hello:
  [cscript] hello there, Rhino

-----Original Message-----
From: Rhino [mailto:rhino1@sympatico.ca] 
Sent: Tuesday, January 31, 2006 9:57 AM
To: Ant Users List
Subject: Re: Problems with exec task



----- Original Message ----- 
From: "Steve Loughran" <stevel@apache.org>
To: "Ant Users List" <user@ant.apache.org>
Sent: Tuesday, January 31, 2006 5:01 AM
Subject: Re: Problems with exec task


> Rhino wrote:
>
>> When I did this:
>>
>>    <property name="vbs.script" value="'c:\Documents and
Settings\Rhino\My 
>> Documents\LaunchWdMacro.vbs'"/>
>>
>>    <exec executable="cscript.exe" spawn="true">
>>
>>    <arg line="${vbs.script} Dudley Doright"/>
>>
>>    </exec>
>>
>>
>> everything was fine; there were no errors from Ant and the macro
wrote 
>> Dudley Doright in the document.
>>
>> But when I did this (using the same property definition for
vbs.script):
>>
>>    <exec executable="cscript.exe" spawn="true">
>>
>>    <arg value="${vbs.script}"/>
>>
>>    <arg value="Bugs"/>
>>
>>    <arg value="Bunny"/>
>>
>>    </exec>
>>
>> I got no errors from Ant but the macro didn't run and Bugs Bunny was
not 
>> added to the document. When I tried the same thing with the
spawn="true" 
>> removed, I got an error from Ant:
>>
>> [exec] Microsoft (R) Windows Script Host Version 5.6
>>
>> [exec] Copyright (C) Microsoft Corporation 1996-2001. All rights 
>> reserved.
>>
>> [exec] Input Error: There is no script engine for file extension
".vbs'".
>
> there's an extra single quote at the end of this line. If that really
is 
> your file, that is the problem. On <arg line> ant is probably parsing
and 
> discarding the trailing ' as something it doesnt hand down.
>
The extra single quote in the message is simply the last character in
the 
'vbs.script' property value; it _has_ to be there to close off the one
at 
the start of the property value. There's nothing I can do about that. 
Agreed? Or are you suggesting that a change to the property definition
or 
exec will make your arg/value approach work as well as the arg/line 
approach?

>>
>> [exec] Result: 1
>>
>> Frankly, I'm not sure why these variations don't work but I've got
other 
>> problems on my plate and the first variant in this note works fine so
I'm 
>> inclined to move on to other things rather than work out exactly why
the 
>> variants are failing.
>
> yeah, that's what I'd do. At the same time, this is interesting; some 
> aspect of Windows Scripting host.
>
> A bit of research brings up this file
>
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnancho
r/html/scriptinga.asp
>
> which explains stuff more.
>
> 1. you can have multiple engines plugged in; .vbs and .js are the
default, 
> but I think ActivePerl may fit in too if installed.
>
> 2. There is another format. .wsf, that contains WSH jobs in an XML 
> representation.
>
> 3. if the wrong switch is set in your registry, people can run scripts

> against a remote host.
>
> with #2 you could do some interesting ant integration; create a WSF
file 
> inline. With #3 you could run it remotely.
>
>
> I'd use jscript, of course :)
>
I think I'll pass :-) Word macros and VBScript are enough excitement for
me 
today ;-)

--
Rhino



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.14.25/246 - Release Date:
30/01/2006


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

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


Mime
View raw message