On Friday, October 9, 2015 at 2:53:47 PM UTC-5, Leroy Tennison wrote:
>
> Puppet v3.4.3
>
> What I was specifically hoping to do was:
>
> exec { 'test' :
>
> command => "%comspec% /c (a Windows command-line program with parameters)",
>
> }
>
>
> to avoid having to determine where Windows was installed.  Although 
> 'puppet parser vaildate init.pp' doesn't return an error the client agent 
> reports "...not qualified and no path was specified... " (I realize the 
> parser doesn't catch everything)
>
> I tried variants %%comspec%% and \%comspec\% (puppet parser complained 
> about this) but nothing works.  If this is possible please provide an 
> example of the correct syntax, thanks.
>
> Now for the more general question, are environment variables defined on 
> Windows able to be used at all on the puppet server when specifying an 
> agent action?
>


Yes and no.  The docs for Exec's 'windows' provider 
<http://docs.puppetlabs.com/references/4.2.latest/type.html#exec-provider-windows>
 
say this:

Execute external binaries on Windows systems. As with the posix provider, 
> this provider directly calls the command with the arguments given, without 
> passing it through a shell or performing any interpolation. To use shell 
> built-ins — that is, to emulate the shell provider on Windows — a command 
> must explicitly invoke the shell:
>
exec {'echo foo':
  command => 'cmd.exe /c echo "foo"',
}

The explanation of how to use shell built-ins should apply also to using 
the shell's syntax for referencing environment variables.  Note also that 
you can use powershell for such purposes instead of cmd.exe, and many do so.


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/faa328e8-7382-4f65-8a87-d3361b076890%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to