Error clearly says to use proper quotes
‘netstat -nautp |grep -iE "137|389|445|636" |awk '{print $5}' |cut -d: -f2
|grep -iwE "137|389|445|636"’
Save it in Regiter
Use set_facts to store as a variable
On Thu, 1 Aug 2019 at 8:31 AM, Veera <[email protected]> wrote:
> Hi,
>
> I am trying the below snippet to detect the established ports. but
> Ansible throws an error.
>
> - name: List the port connections
> shell: "netstat -nautp |grep -iE "137|389|445|636" |awk '{print
> $5}' |cut -d: -f2 |grep -iwE "137|389|445|636"
> register: dc_stat
> debug:
> var: dc_stat.stdout_lines
>
> this through's the error
>
> The offending line appears to be:
>
>
> - name: List the port connections
> shell: netstat -nautp |grep -iE "137|389|445|636" |awk '{print $5}'
> |cut -d: -f2 |grep -iwE "137|389|445|636"
>
> ^ here
> We could be wrong, but this one looks like it might be an issue with
> unbalanced quotes. If starting a value with a quote, make sure the
> line ends with the same set of quotes. For instance this arbitrary
> example:
>
>
> foo: "bad" "wolf"
>
>
> Could be written as:
>
>
> foo: '"bad" "wolf"'
>
>
>
> I tried inserted a " " for the shell commands and using vars/pipe also
> ..
> How can i direct the output of "netstat -nautp |grep -iE "137|389|445|636"
> |awk '{print $5}' |cut -d: -f2 |grep -iwE "137|389|445|636"" to a
> variable ?
>
> Or do we have to use backslash(\) as in shell ?
>
>
> --
> 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/3e2a9fa0-7974-4455-baa6-f45b2f690aae%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/3e2a9fa0-7974-4455-baa6-f45b2f690aae%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
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/CAJ%2BRxtS0NNfaYBVidivwMmRGn27cXaYaBcm_CetFX3PEviuPmg%40mail.gmail.com.