Hello Monks, and Happy Holidays!

First off..thanks to any who try to help me. :) I do appreciate it.

The goal: To go out and query our 'lightwaves' (I am a UNIX admin, and lightwaves are stripped-down linux boxes connected to the serial ports of our servers, to give us a remote console)for server/port information. Hard to believe, as of now, we don't have records and we work in a VERY LARGE ENVIRONMENT.

The tools: Hopefully, Perl's Expect.pm.

The drawback: I do not know Expect; I have chosen Perl's Expect module because I am adequate in Perl (although by no means and expert) and am learning more.

The problem: The documentation I've read is like mud to me, which , I guess, is because I don't know Expect and have never played around with pty's, etc.

I can spawn a ssh process, and issue commands to it, but I'm stuck on figuring out how to capture the output.

My ask is two-fold: 1) Does anyone know of a good source to read about using Expect.pm?

2) Given the code snippet below, can anyone guide me on how to capture the output of the 'listdev' command I issued on the lightwave? (plycon1 ). That is the part where I'm running into trouble.

($ssh = Expect->spawn("ssh -l sysadmin $server")) || die "couldn't sp +awn ssh: $!"; unless ($ssh->expect(10,"password")) { die "never got username prompt on $server, " .ssh->exp_error() +,"\n"; } print $ssh "$password\r"; unless ($ssh->expect(10,"sysadmin>")) { die "never got sysadmin prompt on $server, " .ssh ->exp_error( +),"\n"; } print $ssh "listdev\r";
Thank you!

In reply to Expect.pm question by Anonymous Monk

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.