Hi Monks, Hope everybody is doing great..!! Using expect.pm , I am accessing the remote machine, but we can only access things on Linux terminals (TTY things). I have some internal process, which I am accessing using below code but I have to access internal things of that process which I am unable do so.. Below is the code .
use Expect; use IO::Stty; my $sg_viewer = Expect->spawn("ssh -l user <IP address>"); #$sg_viewer -> log_stdout(0); $sg_viewer->expect( 5, '-re', "Password:" ); sleep 1; $sg_viewer->send("user\n"); $sg_viewer->expect( 5, '-re', "passwd@123" ); sleep 1; $sg_viewer->send("su - root\n"); $sg_viewer->expect( 5, '-re', "Password:" ); sleep 1; $sg_viewer->send("user\n"); $sg_viewer->expect( 5, '-re', "newroot" ); sleep 1; $sg_viewer->send("su - mmadmim\n"); $sg_viewer->expect( 5, '-re', "Password:" ); sleep 1; $sg_viewer->send("attachtoprocess\n"); # this is the internal p +rocess which I am accessing... $sg_viewer->interact(); # used interact module here to interact + with process sleep 1; $sg_viewer->send("4"); # sending 4 as process have so many opti +ons to access the internal things.. but code is not going inside. $sg_viewer->send("exit\n");
output of this is:
[mmadmim@SG ~]$ attachtoprocess -------------------------------------------------- The process list: >1. BM 00 2. BM1 00 3. BM2 00 4. BM3 01 5. BM4 01 -------------------------------------------------- Press ESC to quit.
I am sending 4 to access the BM4 ( process of process) but not happening.. any help??

In reply to Interacting with Internal process using Expect.pm by bhushanQA

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.