Hi,

i'm using below code to take health checks for different servers, but I'm getting garbage output in log file, for example : if I fire command "cat /opt/telorb/axe/loadingGroup01_1/Outage/OutageReport* | tail -2" in log file it is coming as Proc_m0_s13$ cat /opt/telorb/axe/loadingGroup01_1/Outage/OutageReport* | tail <b/axe/loadingGroup01_1/Outage/OutageReport* | tail                         -2

Please help me to overcome this problem ........

$exp = new Expect; $exp->restart_timeout_upon_receive(1); $exp->spawn("ssh -l $nodeuser $ip\r"); $exp->log_file("$logpath/$node_name/$node_name.log", "w"); $exp->expect($timeout, ['-re', 'Password:',sub{ $exp->send("$nodepass\r"); } ], ['-re', 'password:',sub{ $exp->send("$nodepass\r"); } ]); # $exp->send("$nodepass\r"); $exp->expect($timeout,"*"); # $exp->notransfer(1); $exp->expect($timeout, [ timeout => sub { die "login Time Out\n"; } ], [ '-re', "$prompt", sub { my $self = shift; foreach my $priority (sort {$a<=>$b} keys %priority_co +mmands) { my %all_commands = %{$priority_commands{$priority} +}; foreach my $commands (keys %all_commands) { $self->clear_accum(); $self->restart_timeout_upon_receive(1); $commands =~ s/[\r\n]//g; $self->send("$commands\n") ; sleep 2; while(1){ sleep(1); $self->expect( [ qr/MORE/i,sub{ $self->send_slow(" "); exp_continue; } ], ['-re', "$prompt",{ last } ]); } sleep 2; } } } ], [ eof => sub { die "ERROR: could not spawn SSH.\n"; } ] ); # $exp->clear_accum(); $exp->expect($timeout,$prompt); $exp->send("exit\n"); $exp->log_file(undef); $exp->soft_close();

it seems that it is a default terminal line-length problem, not really a Perl problem ........... So, can anyone please guide me to how I'll increase the terminal width ....... <\p>

Thanks in advance .....


In reply to Facing Problem with Perl Expect, if the command length is slightly longer is splitting into 2-3 lines with garbage by abhishekrc2007

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.