In my previous question Expect, STDout, and formating I was having difficulty getting output from expect. thanks to the code snipits provided by my fellow monks I am now able to get output, but alas there is a problem making if make sense. normally i wouldnt post a question that could be titled "why wont if make sense" but alas I am totally stuck.

my problems stem from the inconsistencys of expects loging functionality. ie occassionally /bin/sh will be logged as /\nbin/sh. And to top it off dispite having duplicated every case i can thing would effect my output and compensate for the problems no luck was achieved.
hopefully my code will help explain my question more clearly

$exp->log_file(\&formatoutput); $exp->send("$CAT /etc/passwd\n"); ...... sub formatoutput { my $input = shift; chomp($input); $input =~ tr/\r//; if( ($input ne "$CAT /etc/passwd ") || ($input ne '/bin/sh') || ($input ne "/bin/sh") || ($input ne '\$ ') || ($input ne "\$ ") || ($input ne '/') || ($input ne "/") || ($input ne 'bin/sh') || ($input ne "bin/sh") ) { print"${input}\n\n"; } }
the output that I get is
/ bin/sh $ root:x:0:1::/:/sbin/sh daemon:x:1:1::/: bin:x:2:2::/usr/bin: sys:x:3:3 +::/: adm:x:4:4:Admin:/var/adm: lp:x:71:8:Line Printer Admin:/usr/spoo +l/lp: uucp:x:5:5:uucp Admin:/usr/lib/uucp: nuucp:x:9:9:uucp Admin:/va +r/spool/uucppublic:/usr/lib/uucp/uucico listen:x:37:4:Network Admin:/ +usr/net/nls: nobody:x:60001:60001:Nobody:/: noaccess:x:60002:60002:No + Access User:/: nobody4:x:65534:65534:SunOS 4.x Nobody:/: fast:x:204: +1:FastTrack Server:/web:/bin/sh postfix:x:100:1:postfix:/dev/null:/bi +n/false vscan:x:1001:10:Amavis User:/usr/local/encap/amavis-perl-11:/ +bin/sh sshd:x:22000:22000:SSHD privsep User:/var/empty:/bin/false $
neither of the $'s or the / or bin/sh should be showing up and last run i had the $ and /bin/sh which should also have not shown up, right?

In reply to inconsisntency, if, expect, logs by jcpunk

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.