Welcome to the new Linux Foundation Forum!

Telnet logging

Hello everyone. I have a script that telnets into a linux workstation and restarts a service, while logging the session to a file. I'm kind of new to linux so when I was using windows I would capture something like

windows cli: telnet xxx.xxx.xxx.xxx -f c:/capture.log

...

[[email protected]]# /sbin/service dhcpd restart

Shutting down dhcpd: OK]

Starting dhcpd: OK]

Now when using the linux telnet client I capture something like

[[email protected]]# telnet xxx.xxx.xxx.xxx | tee -a /users/me/capture.log

...

[[email protected]]# /sbin/service dhcpd restart

Shutting down dhcpd: [60G[ [0;32mOK[0;39m ]

Starting dhcpd: [60G[ [0;32mOK[0;39m ]

It looks like the telnet session is passing control characters or something like that to the log file, which messes up some scripts that check whether the service was succesfully restarted.

I've already tried playing around with the telnet mode (line vrs char) with no effect. Any ideas on how to get the log with just plain text?

Thanks for any advice and sorry if I posted in the wrong place.

Comments

  • marcmarc Posts: 647
    Elyas_CR wrote:
    Hello everyone. I have a script that telnets into a linux workstation and restarts a service, while logging the session to a file. I'm kind of new to linux so when I was using windows I would capture something like

    windows cli: telnet xxx.xxx.xxx.xxx -f c:/capture.log
    ...
    [[email protected]]# /sbin/service dhcpd restart
    Shutting down dhcpd: OK]
    Starting dhcpd: OK]

    Now when using the linux telnet client I capture something like

    [[email protected]]# telnet xxx.xxx.xxx.xxx | tee -a /users/me/capture.log
    ...
    [[email protected]]# /sbin/service dhcpd restart
    Shutting down dhcpd: [60G[ [0;32mOK[0;39m ]
    Starting dhcpd: [60G[ [0;32mOK[0;39m ]

    It looks like the telnet session is passing control characters or something like that to the log file, which messes up some scripts that check whether the service was succesfully restarted.
    I've already tried playing around with the telnet mode (line vrs char) with no effect. Any ideas on how to get the log with just plain text?

    Thanks for any advice and sorry if I posted in the wrong place.

    [ rant on]
    TELNET MUST DIE
    [rant off]
    [[email protected]]# telnet xxx.xxx.xxx.xxx | tee -a /users/me/capture.log
    

    Why don't you try with:
    [[email protected]]# telnet xxx.xxx.xxx.xxx >> /users/me/capture.log
    

    Or if you insist to use tee, try with the -i option:
    [[email protected]]# telnet xxx.xxx.xxx.xxx | tee -a  -i /users/me/capture.log
    

    Regards
Sign In or Register to comment.