Topic
  • 2 replies
  • Latest Post - ‏2004-07-23T21:52:06Z by SystemAdmin
SystemAdmin
SystemAdmin
232 Posts

Pinned topic strange chars in Expect log_file

‏2004-04-16T11:34:10Z |
Hi,
I'm fairly new to tcl and expect. I'm using expect to ssh into another account, and dump the contents of a directory (via "ls -la").

I'm using log_file in order to get the stdout into a file on my machine.
When I open this file later on (vi) I see some strange characters, at the end of every line:
drwx------ 3 root root 4096 Apr 14 06:54 ^[[00m.bashrc^[[00m

this line displays normally this way:
drwx------ 3 root root 4096 Apr 14 06:54 .bashrc

What am I missing here?

Here is the script (very short):
#! /usr/bin/expect --
spawn ssh -l newuser 127.0.0.1
expect "assword:"
send "newpass\r"
expect "]$ "
send "ls -la\r"
log_file outfile
expect "]$ "

Thanks,
Walter J.
Updated on 2004-07-23T21:52:06Z at 2004-07-23T21:52:06Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    232 Posts

    Re: strange chars in Expect log_file

    ‏2004-05-13T18:27:20Z  

    My guess is the extra characters are caused by your
    terminal color coding the output, you probable have
    an alias for "ls" such as "ls -F --color=auto",
    unset the alias before you run the command after you
    log in.

    Also, you can add a line in the script "exp_internal 1" to see the
    raw output of the characters as expect would
    see them. This is invaluable to debugging expect scripts.
  • SystemAdmin
    SystemAdmin
    232 Posts

    Re: strange chars in Expect log_file

    ‏2004-07-23T21:52:06Z  
    thats most probably the terminal chars as already pointed out. another simpilar option would be to use a simpilar command like

    ssh server command

    after generating keys on th ebox where you are running your script and copying the public key to the server.
    hth
    -b-