in reply to inconsisntency, if, expect, logs

I have not seen this before, and have used expect a lot. Could you post more of your code (the parts that generate the output, and buid $exp) so I can see if it is the way $exp was formed or the commands were run that is causing this. Also a raw dump of the $exp->log_file written to a file with the portion that you show uncorrectly formatted would be helpful.

-Waswas

Replies are listed 'Best First'.
Re: Re: inconsisntency, if, expect, logs
by jcpunk (Friar) on Jun 13, 2003 at 18:48 UTC
    here is some more code
    my $exp = new Expect; .... $exp->raw_pty(1); $exp->log_stdout(0); $exp->spawn($telnet $host);||die; $exp->expect($timeout, ['ogin:', sub { $exp->send("$username\n"); exp_contin +ue; } ], ['assword:', sub { $exp->send("$password\n"); } ], [timeout => sub { die "<center>ERROR: <BR>A timeout h +ast occured at login</center>\n"; } ], ); $exp->log_file(\&formatoutput); $exp->send("/bin/sh\n");
    that comprises the rest of my expect usage in this file excluding the soft_close I would be willing to post the whole file, but it is around 600 lines and the rest isnt relavent i think....
      The expect flags look correct, I guess my question is if you just dump the $exp->log_file to a normal file does the file contain an extra \n in the /bin/sh line(s)?

      -Waswas
        hmmmm, just tested that and no it does not.... looks just fine.
        /bin/sh $ root:x
        which is weird, but with Thelonius's comment I am able to parse out most of what i want to so im not terribly concerned. but i do still have one weird issue.

        i changed my if statement to an unless but i still get bin/sh at the top(

        bin/sh root:x:0:1::
        ), here is my unless if you desire to examine it
        unless( ($input eq "/bin/sh") || ($input eq "\$ ") || ($input eq "/") || ($input eq "bin/sh") )
        as for the strangeness of expect's loging perhaps just deciding that Sun's perl 5.8 package is slightly broken would be a good idea as I gave a friend a copy over lunch and his linux box doesn't generate the \n (just got an email from him on that)