Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
1 reply Latest Post - ‏2004-12-23T21:06:14Z by SystemAdmin
SystemAdmin
SystemAdmin
232 Posts
ACCEPTED ANSWER

Pinned topic expect script help

‏2004-11-30T22:48:10Z |
How do I filter a meta character like "^M" in expect? I capture the output from a telnet session and want to get rid off theses line feeds. I figured out that if the command length exceeds 80 chars, it is putting a line feed in the echo of the command. I'm expecting "string trim" to remove the "^M" but it is not. Any ideas?

Here is a snippet of code
code
log_file -a junk.log
set command "a quick brown fox jumps over a lazy dog a quick brown fox jumps over a lazy dog."
send "$command\r"
expect "\n"
set buf $expect_out(buffer)
set buf
send_user $buf
log_file
[/code]

The log file looks like this:
[i]
a quick brown fox jumps over a lazy dog a quick brown fox jumps ove ^Mr a lazy dog.
a quick brown fox jumps over a lazy dog a quick brown fox jumps ove ^Mr a lazy dog.
[/i]
Updated on 2004-12-23T21:06:14Z at 2004-12-23T21:06:14Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    232 Posts
    ACCEPTED ANSWER

    Re: expect script help

    ‏2004-12-23T21:06:14Z  in response to SystemAdmin
    In this line
    set buf
    try changing it to read
    set buf

    Not an expert on expect but I think I read this somewhere.

    themartellekid