This will be because you are using the full result from win_shell which 
includes things like changed, rc, stdout, stderr, etc. You need to do `- 
win_shell: "{{ pingpath.stdout |trim }} 9.9.9.9" and say you want to use 
the stdout value of the result which contains the full path. The | trim is 
also needed to trim the newline the stdout result will have.

Putting that aside what is the purpose here, it's inefficient because you 
are now using 2 tasks which involves setting up the connection and running 
a command when you can just achieve it normally in one task and rely on the 
normal PATH lookup. It also is more complicated because you might need to 
quote the value if the path contains a space in it.

- win_command: ping.exe 9.9.9.9

On Saturday, January 27, 2024 at 2:53:28 AM UTC+10 Todd Lewis wrote:

> I'd start by adding a debug step to show what you actually registered:
>
> - name: Show what got registered in pingpath
>   ansible.builtin.debug:
>     msg: "{{ pingpath }}"
>
> Given that using it that way produced unexpected results, perhaps it's 
> because the registered data aren't what you expect.
>
>
> On 1/26/24 10:20 AM, [email protected] wrote:
>
> hi, 
> i want to use "get-command" to get the location of a program. in the next 
> step i want to execute this program with a full qualified location.
> this example is just an example, i know there are other modules for doing 
> a ping.
>
> i use 
> (get-command ping).source
> to get the location. in the next step i want to execute this with a 
> parameter:
>
> - name: get pingpath
>   win_shell: "(get-command ping).source")
>   register: pingpath
> - name test ping
>   win_shell: "{{ pingpath }} 9.9.9.9"
>
> that throws an error because of an
> unexpected token: \":\"
>
> any idea how to fix this?
>
> regards,
> andre
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f0822e19-92cb-415b-8d6c-8418bfe6dc83n%40googlegroups.com.

Reply via email to