I've offered all the help I can. Your best bet is to contact the people who
wrote the program you are trying to use.

You may find it easier to do things like set environment variables and
redirect output using the shell module:

https://docs.ansible.com/ansible/latest/modules/shell_module.html#shell-module

Also, it would be a VERY good idea to test things out manually before
trying to do them in Ansible.

Good luck, K.


On Sun, Apr 19, 2020 at 4:26 PM Samir Kothawade <kothawade.sa...@gmail.com>
wrote:

>
>
> On Sun, 19 Apr 2020 at 05:24, Karl Auer <ka...@2pisoftware.com> wrote:
>
>> TERM=dumb
>>
>> Sorry, I mistyped. The minus sign should have been an equals sign.
>>
>> >> >> Can you please help me where I can use this in my code and see the
> content in a text file ? Here is  my anible code...pasting it here again
>  *-** hosts: sam*
> *  gather_facts: no*
> *  tasks:*
> *  - name: capture all stats*
> *    ignore_errors: yes*
> *    expect:*
> *      command: /opt/abc/xyz_Platform/bin/go_xyz_cli*
> *      responses:*
> *        (.*)Username:(.*): "admin"*
> *        (.*)Password:(.*): "admin"*
> *        (.*)xyz_cli>(.*): display all debug stats*
> *        (.*):(.*): ''*
> *    register: stats*
> *  - local_action: copy content="{{ stats.stdout}}"
> dest="/home/sam/quickstats/stats.txt"*
> *    ignore_errors: yes*
>
>> The idea is to set the environment variable TERM to the value "dumb"
>> immediately before starting the shell in which your program will be run.
>>
>> Also can you please answer the question about whether you can redirect
>> the output of this program?
>>
>
> >> NO. There no support on that binary to copy or to point the output to
> some file. Shell commads like " >>abc.txt " does not work.
>
>>
>> I strongly suggest you experiment manually rather than with Ansible. You
>> need to find out how to achieve what you want, then duplicate that in
>> Ansible. Doing both at once is very painful.
>>
>>
> >>  Yes. I have done this manually.
> *For collecting stats manually here is the procedure :*
> 1. I use mouse > Select the area of stats appeared on screen (after
> selecting area, termius utility copy the selected area automatically) >
> 2. Paste it manually by pressing ctr+v into sublime text editor
> 3. Again go to remote machine and press down key/Enter key to collect
> remaining stats and copy-paste the status in similarly way as mentioed in
> step 1 and 2.
> 4. I have to perform step 1,2,3 multiple times untill I copy all the
> status, as window can display only 25-30 lines/rows. Some times for doing
> it quickly, I use zoom-out (Ctr++), by this I can copy more lines.
>     But I want to do this operation through automation.
>
>> Regards, K.
>>
>> On Sun, Apr 19, 2020 at 2:34 AM Samir Kothawade <
>> kothawade.sa...@gmail.com> wrote:
>>
>>> bash: TERM-dumb: command not found.
>>>
>>> gnome-terminal utility not available on remote  machine
>>>
>>>
>>> On Sat, 18 Apr 2020 at 21:53, Karl Auer <ka...@2pisoftware.com> wrote:
>>>
>>>> You *might* be able to convince the console on the remote system to be
>>>> a dumb terminal by doing this as your command:
>>>>
>>>> TERM-dumb ; sh -c your_command
>>>>
>>>> This works in gnome-terminal as well - it seems to suppress most
>>>> control sequences except CR/LF and similar.
>>>>
>>>> Or in Ansible, setting the environment variable TERM to "dumb" then
>>>> running your command in a new shell. In my experiments here, when I set
>>>> TERM=dumb and ran sh from within a console or from within
>>>> gnome-terminal, the colourisation went away. However the console still
>>>> had a fixed number of lines.
>>>>
>>>> Regards, K.
>>>>
>>>> On Sun, Apr 19, 2020 at 1:04 AM Samir Kothawade <
>>>> kothawade.sa...@gmail.com> wrote:
>>>>
>>>>>
>>>>>
>>>>> >> Could you please explain how can use xterm command : xterm --tn
>>>>> dumb -cm -dc -e this is your command
>>>>>    Fustratigly, xterm is not present in remote  machine and I am not
>>>>> allowed to install xterm utility on targeted remote machine. Still, is
>>>>> there any way to run it through ansible conroller?
>>>>>
>>>>>
>>>>> On Saturday, 18 April 2020 14:45:18 UTC+5:30, Samir Kothawade wrote:
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> *Here is the brief about scenario: *
>>>>>>
>>>>>> 1. login to Debian host machine using ansible
>>>>>> 2. Go to corresponding directory where the binary is and execute that
>>>>>> binary. (This binary is written in c and C++. After execution it ask for
>>>>>> the userid & password)
>>>>>> 3. After login into that binary's shell, it  has several commands
>>>>>> which displays statistics. Those stats are lengthy and does not fit in
>>>>>> current screen resolution. For seen seeing all the stats we have to press
>>>>>> Down arrow Key or Enter key multiple time until we reach to last stat 
>>>>>> line.
>>>>>>
>>>>>> *How I am doing this: *
>>>>>>
>>>>>> *-** hosts: sam*
>>>>>> *  gather_facts: no*
>>>>>> *  tasks:*
>>>>>> *  - name: capture all stats*
>>>>>> *    ignore_errors: yes*
>>>>>> *    expect:*
>>>>>> *      command: /opt/abc/xyz_Platform/bin/go_xyz_cli*
>>>>>> *      responses:*
>>>>>> *        (.*)Username:(.*): "admin"*
>>>>>> *        (.*)Password:(.*): "admin"*
>>>>>> *        (.*)xyz_cli>(.*): display all debug stats*
>>>>>> *        (.*):(.*): ''*
>>>>>> *    register: stats*
>>>>>> *  - local_action: copy content="{{ stats.stdout}}"
>>>>>> dest="/home/sam/quickstats/stats.txt"*
>>>>>> *    ignore_errors: yes*
>>>>>>
>>>>>>
>>>>>> *Issues Facing : *
>>>>>>
>>>>>> 1. Multiple similar line gets copied in stats.txt file when above
>>>>>> reaches to ==>>*  (.*):(.*): ''*  (See above code section marked in
>>>>>> blue). Using this method to press <enter> key.
>>>>>> 2. Actual stats counts are of line 500 hundred but above code returns
>>>>>> 2k + stats with repetitive stats and some garbage values appended.
>>>>>> 3. If i removes this  portion *  (.*):(.*): ''*  from code, then
>>>>>> above script only copies 20-30 lines which currently are displayed on
>>>>>> screen or which displayed in current screen size.
>>>>>>
>>>>>>
>>>>>> I guess I can achieve this by changing remote servers' screen size.
>>>>>> but I could not able to get any such way in ansible.
>>>>>>
>>>>>>
>>>>>> May I request you to help me in this ?
>>>>>>
>>>>> --
>>>>> 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/2f760261-f3ca-420b-86a5-d9eb2ed85206%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/ansible-project/2f760261-f3ca-420b-86a5-d9eb2ed85206%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> *Karl Auer* { manager, systems support }
>>>> P: 1300 759 975
>>>> E: ka...@2pisoftware.com
>>>> 2pisoftware.com
>>>>
>>>> GPG/PGP : DF6A 43E5 FB9D D884 C6CA CD7F 5278 212D E80F C107
>>>> Previous: 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
>>>>
>>>> --
>>>> 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/CA%2B%2BT08SQ_etTQUJ%2BfTYMb1Jn-u-rd8m4BTJBnaoFhOf%2BL70Fbg%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08SQ_etTQUJ%2BfTYMb1Jn-u-rd8m4BTJBnaoFhOf%2BL70Fbg%40mail.gmail.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/CAA%3Dr5yczMNb4QMRUxG5S5wKE9PF04_0VSx21D%3Duo0CLXGWd6dQ%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/ansible-project/CAA%3Dr5yczMNb4QMRUxG5S5wKE9PF04_0VSx21D%3Duo0CLXGWd6dQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>
>>
>> --
>>
>> *Karl Auer* { manager, systems support }
>> P: 1300 759 975
>> E: ka...@2pisoftware.com
>> 2pisoftware.com
>>
>> GPG/PGP : DF6A 43E5 FB9D D884 C6CA CD7F 5278 212D E80F C107
>> Previous: 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
>>
>> --
>> 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/CA%2B%2BT08TpNfzdFb4WkkKAaL4iH36w1dr2_HuE2WC5kad6jygFog%40mail.gmail.com
>> <https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08TpNfzdFb4WkkKAaL4iH36w1dr2_HuE2WC5kad6jygFog%40mail.gmail.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/CAA%3Dr5ydHjjaDdjDCDZVxc%3DL6tuSgkNgZyF0%2BQWmQhhC2Y2DOkA%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAA%3Dr5ydHjjaDdjDCDZVxc%3DL6tuSgkNgZyF0%2BQWmQhhC2Y2DOkA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : DF6A 43E5 FB9D D884 C6CA CD7F 5278 212D E80F C107
Previous: 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E

-- 
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/CA%2B%2BT08SXbf1r0J8GPymE6px4TqWiXAPT6Hj3dBc06Jd5J2xCFQ%40mail.gmail.com.

Reply via email to