Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I do an "ls -l" on my linux box over PuTTY, it gives a clean, nicely colored output.

But when I try the same programmatically over plink, I land up getting all sort of control sequences, likely signifying those color values.

Can I somehow set the terminal options so that it doesn't send out these extra sequences for the colors, and just emits plain text?

[00mtotal 8956
drwxr-xr-x 8 pradymn users    4096 2010-07-23 12:29 [01;34mtestsb1[00m
drwxr-xr-x 5 pradymn users    4096 2010-07-24 22:49 [01;34mtest1[00m
-rw-r--r-- 1 pradymn users 9143013 2010-07-24 23:03 [00;31mtest1.tar.gz[00m
share|improve this question

4 Answers 4

up vote 1 down vote accepted

This is probably related to how you setup your ls to display colors. If you can post that we might be more helpful.

I recommend using the following in your favorite shell profile file (.bashrc): alias ls="ls --color=auto"

Alternatively when you don't want color output you can call ls using --color=never

share|improve this answer
    
Thanks. The --color=never works great :) –  Pradyumna Aug 1 '10 at 13:46

Another alternative is to use the ansicon utility that sits between the console and plink and translates ANSI color codes on the fly:

$ ansicon.exe plink.exe user@host
share|improve this answer

To add to Rob's answer:

The ANSI escape sequences have to be interpreted by a terminal emulator program (or by a real hardware terminal). PuTTY is both a terminal emulator and a SSH client in one program.

But plink is just a SSH client designed to transfer raw binary data; it does not interpret ANSI sequences, just passes them to the terminal it is running in. On Windows, the terminal is the Windows console — and it does not support ANSI either.

If you want to use SSH from command line, try the Cygwin version of OpenSSH. PuTTY can be launched from command line too.

share|improve this answer

You could remove ANSI escape sequences with the following java regex (for exemple):

\\[..;..[m]|\\[.{0,2}[m]|\\(Page \\d+\\)|\u001B\\[[K]|\u001B|\u000F
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.