in reply to Re: inconsisntency, if, expect, logs
in thread inconsisntency, if, expect, logs

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....

Replies are listed 'Best First'.
Re: Re: Re: inconsisntency, if, expect, logs
by waswas-fng (Curate) on Jun 13, 2003 at 19:15 UTC
    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)
        Does $|++; at the top of your script make any difference? Are you using 5.8 from sunfreeware.com, compiled yourself or a sun package? I have compiled my self and used sunfreeware all over the place and not seen this before. There has to be something wierd going on here this is not normal. also could you try a cat -v <filename> on that output file and see if there are any wierd characters in the /bin/sh line?

        -Waswas