I am launching the SSH utility bundled with Cygwin, using ProcessBuilder Class in Java. Everything works fine. I connect to a linux server over SSH, can run commands and read the output.
However, whenever the output is returned, it only happens after login on the server and running commands e.g directory listing ls
, returns something like this:
InputStream: root@myserver:/scripts/common# ls
InputStream: [00m[00mA1-4.yaml[00m [01;32mscip-1.2.0.linux.x86_64.gnu.opt.qso[00m
InputStream: [00madditional_files.txt[00m [01;32mscip-1.2.0.linux.x86_64.gnu.opt.spx[00m
As far as I have figured out, it is only happening with file listing command. For example when I am running other commands like time, etc it shows normal output.
Can you suggest what it is that is appending these random characters to the filename?
I have even tried to use UTF8 encoding but nothing changes. When I directly login using the command line, I do not see those results. However, the cmdline shows file names in colored values. Is it that there is some additional information added which is not ASCII?
Using the command ls --color=none
solves this problem.
This happens because by default ls command returns file names which have different color code values appended to them. This link gives more information.
Following picture describes the difference between ls
and ls --color=none
: