G'day your holiness,
I am a babe in Perl but have a pretty good feel for it but very new to objects. I am attempting to use the Expect.pm to automate some daily reports but am having trouble understanding how to get my StdOut from the command being ran by Expect...any and all help is greatly appreciated. Here is the code that I have and the resulting DEBUG below it. My Expect functions are matching and sending the correct responses to the username and password but immediately hard_close() without returning the output from the command...just not clear in my mind how to send it to an array for processing.
As always THANKS,
Danny
#!/usr/bin/perl -w $ENV{'RTSERVERS'} = 'tcp:dspmon03.tdc.cingular.net:2059,tcp:dspmon01.t +dc.cingular.net:2059'; use Expect; use strict; $Expect::Log_Stdout=1; $Expect::Debug=3; $Expect::Exp_Internal=1; my $cmd = "/opt/app/bmcprod/common/bmc/bin/solaris-2-10-sparc/pslv -a +"-id DSPMON03" ./cs_get_agent_info.asm"; new Expect(); (my $rtcloud = Expect->spawn("$cmd")) || die "Couldn't spawn $cmd, $!" +; unless ($rtcloud->expect(30,"Enter a user name for the service 'PATROL +_CSERVER_DSPMON03' :")) { die "Never got username prompt from $cmd, ".$rtcloud->exp_error()."\ +n"; } print $rtcloud "b1patrol\r"; unless ($rtcloud->expect(30,"Password: ")) { die "Never got Password prompt from $cmd, ".$rtcloud->exp_error()."\ +n"; } print $rtcloud "xxxxxxxx\r";

DEBUG
Use of uninitialized value in concatenation (.) or string at /usr/loca +l/lib/perl5/site_perl/5.8.8/Expect.pm line 1431. Closing . at /usr/local/lib/perl5/site_perl/5.8.8/Expect.pm line 1431 Expect::hard_close('Expect=GLOB(0x1005dcad0)') called at /usr/ +local/lib/perl5/site_perl/5.8.8/Expect.pm line 1621 Expect::DESTROY('Expect=GLOB(0x1005dcad0)') called at ./get_RT +cloud.pl line 14 eval {...} called at ./get_RTcloud.pl line 14 Expect::new('Expect') called at ./get_RTcloud.pl line 14 Use of uninitialized value in concatenation (.) or string at /usr/loca +l/lib/perl5/site_perl/5.8.8/Expect.pm line 1434. closed. Spawned '/opt/app/bmcprod/common/bmc/bin/solaris-2-10-sparc/pslv -a "- +id DSPMON03" ./cs_get_agent_info.asm' spawn id(3) Pid: 7293 Tty: /dev/pts/6 at /usr/local/lib/perl5/site_perl/5.8.8/Expect.pm line 181 Expect::spawn('Expect', '/opt/app/bmcprod/common/bmc/bin/solar +is-2-10-sparc/pslv -a "-...') called at ./get_RTcloud.pl line 16 expect(Expect=GLOB(0x1006afec0) 30 Enter a user name for the service ' +PATROL_CSERVER_DSPMON03' :) called... expect(): handling param 'Enter a user name for the service 'PATROL_CS +ERVER_DSPMON03' :'... expect(): exact match 'Enter a user name for the service 'PATROL_CSERV +ER_DSPMON03' :'... Starting EXPECT pattern matching... at /usr/local/lib/perl5/site_perl/5.8.8/Expect.pm line 561 Expect::expect('Expect=GLOB(0x1006afec0)', 30, 'Enter a user n +ame for the service \'PATROL_CSERVER_DSPMON03\' :') called at ./get_R +Tcloud.pl line 18 spawn id(3): beginning expect. Timeout: 30 seconds. Current time: Tue Aug 14 15:40:11 2007 spawn id(3): list of patterns: #1: -ex `Enter a user name for the service \'PATROL_CSERVER_DSPMON03 +\' :' spawn id(3): Does `' match: pattern #1: -ex `Enter a user name for the service \'PATROL_CSERVER_ +DSPMON03\' :'? No. Waiting for new data (30 seconds)... spawn id(3): new data. spawn id(3): read 153 byte(s). INFO: Connecting to Global Namespace using tcp:dspmon03.tdc.cingular.n +et:2059,tcp:dspmon01.tdc.cingular.net:2059... INFO: Setting authentication hooks spawn id(3): Does `INFO: Connecting to Global Namespace using tcp:dspm +on03.tdc.cingular.net:2059,tcp:dspmon01.tdc.cingular.net:2059...\r\nI +NFO: Setting authentication hooks\r\n' match: pattern #1: -ex `Enter a user name for the service \'PATROL_CSERVER_ +DSPMON03\' :'? No. Waiting for new data (29 seconds)... spawn id(3): new data. spawn id(3): read 63 byte(s). Enter a user name for the service 'PATROL_CSERVER_DSPMON03' : spawn id(3): Does `INFO: Connecting to Global Namespace using tcp:dspm +on03.tdc.cingular.net:2059,tcp:dspmon01.tdc.cingular.net:2059...\r\nI +NFO: Setting authentication hooks\r\n\r\nEnter a user name for the se +rvice \'PATROL_CSERVER_DSPMON03\' :' match: pattern #1: -ex `Enter a user name for the service \'PATROL_CSERVER_ +DSPMON03\' :'? YES!! Before match string: `INFO: Connecting to Global Namespace using t +cp:dspmon03.tdc.cingular.net:2059,tcp:dspmon01.tdc.cingular.net:2059. +..\r\nINFO: Setting authentication hooks\r\n\r\n' Match string: `Enter a user name for the service \'PATROL_CSERVER_ +DSPMON03\' :' After match string: `' Matchlist: () Returning from expect successfully. spawn id(3): accumulator: `' expect(Expect=GLOB(0x1006afec0) 30 Password: ) called... expect(): handling param 'Password: '... expect(): exact match 'Password: '... Starting EXPECT pattern matching... at /usr/local/lib/perl5/site_perl/5.8.8/Expect.pm line 561 Expect::expect('Expect=GLOB(0x1006afec0)', 30, 'Password: ') c +alled at ./get_RTcloud.pl line 24 spawn id(3): beginning expect. Timeout: 30 seconds. Current time: Tue Aug 14 15:40:12 2007 spawn id(3): list of patterns: #1: -ex `Password: ' spawn id(3): Does `' match: pattern #1: -ex `Password: '? No. Waiting for new data (30 seconds)... spawn id(3): new data. spawn id(3): read 10 byte(s). b1patrol spawn id(3): Does `b1patrol\r\n' match: pattern #1: -ex `Password: '? No. Waiting for new data (30 seconds)... spawn id(3): new data. spawn id(3): read 58 byte(s). Password required for the user 'b1patrol' on service 'PATR spawn id(3): Does `b1patrol\r\nPassword required for the user \'b1patr +ol\' on service \'PATR' match: pattern #1: -ex `Password: '? No. Waiting for new data (27 seconds)... spawn id(3): new data. spawn id(3): read 23 byte(s). OL_CSERVER_DSPMON03'. spawn id(3): Does `b1patrol\r\nPassword required for the user \'b1patr +ol\' on service \'PATROL_CSERVER_DSPMON03\'.\r\n' match: pattern #1: -ex `Password: '? No. Waiting for new data (27 seconds)... spawn id(3): new data. spawn id(3): read 10 byte(s). Password: spawn id(3): Does `b1patrol\r\nPassword required for the user \'b1patr +ol\' on service \'PATROL_CSERVER_DSPMON03\'.\r\nPassword: ' match: pattern #1: -ex `Password: '? YES!! Before match string: `b1patrol\r\nPassword required for the user \ +'b1patrol\' on service \'PATROL_CSERVER_DSPMON03\'.\r\n' Match string: `Password: ' After match string: `' Matchlist: () Returning from expect successfully. spawn id(3): accumulator: `' Closing spawn id(3). at /usr/local/lib/perl5/site_perl/5.8.8/Expect.pm line 1431 Expect::hard_close('Expect=GLOB(0x1006afec0)') called at /usr/ +local/lib/perl5/site_perl/5.8.8/Expect.pm line 1621 Expect::DESTROY('Expect=GLOB(0x1006afec0)') called at ./get_RT +cloud.pl line 0 eval {...} called at ./get_RTcloud.pl line 0 spawn id(3) closed. Pid 7293 of spawn id(3) terminated, Status: 0x01

In reply to Expect.pm dealing with STDOUT by onegative

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.