Thanks Vinoth. It worked Yes . I learnt that we can use the formatting as in python either with ' ' or " ".
On Thursday, August 1, 2019 at 8:59:32 AM UTC+5:30, vinoth kumar wrote: > > > > On Thu, 1 Aug 2019 at 8:57 AM, vinoth kumar <vinod...@gmail.com > <javascript:>> wrote: > >> Error clearly says to use proper quotes >> This would be fine i think so >> “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 <svee...@gmail.com <javascript:>> >> 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 ansible...@googlegroups.com <javascript:>. >>> 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b1841eaa-5c31-4a98-b975-a279a020d22c%40googlegroups.com.