Windows exec resource cannot find command error

23 views
Skip to first unread message

Michael Watters

unread,
Dec 7, 2020, 12:17:26 PM12/7/20
to Puppet Users
I have an exec resource in a manifest for our Windows nodes however the command is failing each time that puppet runs.  Here is the definition of the resource and a screenshot of the error.

~> exec { 'telegraf.exe --service install':
        cwd => 'c:/program files/telegraf',
        refreshonly => false,
    }



Is there a way to resolve this?  I've tried changing the path parameters which doesn't make any difference.


Martin Alfke

unread,
Dec 7, 2020, 2:06:53 PM12/7/20
to Puppet Users
Have you tried using the full path to the executable?

exec { 'c:/program files/telegraf/telegraf.exe --service install' :
...
}

> On 7. Dec 2020, at 18:17, Michael Watters <watt...@gmail.com> wrote:
>
> I have an exec resource in a manifest for our Windows nodes however the command is failing each time that puppet runs. Here is the definition of the resource and a screenshot of the error.
>
> ~> exec { 'telegraf.exe --service install':
> cwd => 'c:/program files/telegraf',
> refreshonly => false,
> }
>
>
>
> Is there a way to resolve this? I've tried changing the path parameters which doesn't make any difference.
>
>
>
> --
> 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...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/ca2819ca-1930-4842-8ed8-0820f19ea343n%40googlegroups.com.

Michael Watters

unread,
Dec 8, 2020, 1:29:55 PM12/8/20
to Puppet Users
I tried that as well and it simply results in an error stating "Could not find command: c:/program".

Michael Watters

unread,
Dec 8, 2020, 1:37:03 PM12/8/20
to Puppet Users
Here is the exact error message.

Info: /Stage[main]/Dart::Abstract::Windows_node/File[c:/program files/telegraf/telegraf.conf]: Scheduling refresh of Exec[c:/program files/telegraf/telegraf.exe --service install]
Error: Could not find command 'c:/program'
Error: /Stage[main]/Dart::Abstract::Windows_node/Exec[c:/program files/telegraf/telegraf.exe --service install]/returns: change from 'notrun' to ['0'] failed: Could not find command 'c:/program'

The manifest resource is defined as follows.

exec { 'c:/program files/telegraf/telegraf.exe --service install':
        cwd => 'c:/program files/telegraf',
        refreshonly => true,
 }

Josh Cooper

unread,
Dec 8, 2020, 1:58:12 PM12/8/20
to puppet...@googlegroups.com
On Tue, Dec 8, 2020 at 10:37 AM Michael Watters <watt...@gmail.com> wrote:
Here is the exact error message.

Info: /Stage[main]/Dart::Abstract::Windows_node/File[c:/program files/telegraf/telegraf.conf]: Scheduling refresh of Exec[c:/program files/telegraf/telegraf.exe --service install]
Error: Could not find command 'c:/program'
Error: /Stage[main]/Dart::Abstract::Windows_node/Exec[c:/program files/telegraf/telegraf.exe --service install]/returns: change from 'notrun' to ['0'] failed: Could not find command 'c:/program'

The manifest resource is defined as follows.

exec { 'c:/program files/telegraf/telegraf.exe --service install':
        cwd => 'c:/program files/telegraf',
        refreshonly => true,
 }

On Tuesday, December 8, 2020 at 1:29:55 PM UTC-5 Michael Watters wrote:
I tried that as well and it simply results in an error stating "Could not find command: c:/program".

Probably need to quote the executable due to spaces:

exec { '"c:/program files/telegraf/telegraf.exe" --service install': 
...


On Monday, December 7, 2020 at 2:06:53 PM UTC-5 Martin Alfke wrote:
Have you tried using the full path to the executable?

exec { 'c:/program files/telegraf/telegraf.exe --service install' :
...
}

> On 7. Dec 2020, at 18:17, Michael Watters <watt...@gmail.com> wrote:
>
> I have an exec resource in a manifest for our Windows nodes however the command is failing each time that puppet runs. Here is the definition of the resource and a screenshot of the error.
>
> ~> exec { 'telegraf.exe --service install':
> cwd => 'c:/program files/telegraf',
> refreshonly => false,
> }
>
>
>
> Is there a way to resolve this? I've tried changing the path parameters which doesn't make any difference.
>
>
>
> --
> 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...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/ca2819ca-1930-4842-8ed8-0820f19ea343n%40googlegroups.com.

--
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...@googlegroups.com.

Michael Watters

unread,
Dec 8, 2020, 5:25:21 PM12/8/20
to Puppet Users
Probably need to quote the executable due to spaces:

exec { '"c:/program files/telegraf/telegraf.exe" --service install': 

Looks like that worked.  Thanks for the help.

Martin Alfke

unread,
Dec 9, 2020, 3:05:43 AM12/9/20
to puppet...@googlegroups.com
Or even escape the whitespace:

exec { “c:/program\ files/telegraf/telegraf.exe --service install": 

Reply all
Reply to author
Forward
0 new messages