# corrupted shell output



## cad (Feb 18, 2009)

Hi world.

I have an issue that Im lost on how to fix.

When i log via ssh shell, all the output displayed is scrambled.

if i use ls or ls -al to view the files they look like this. 

H?!??
H?i??
H?t??
H?f??

instead of 

.
..
foldername
filename

and so on.
i can still view the files content but all folders and file names are displayed in this format.

I suspect it may be due to a corrupted charset of something like that, and I was wondering if anyone else has come across this issue before.

Is there a way to check if it is a charset issue or could it be an issue with 'ls' since when i either cat the file or vi the file i can see plain text.

Thanks in advanced

Cad


----------



## cad (Feb 18, 2009)

Oh I forgot the details.

its FreeBSD 5.3-RELEASE #0

shell access with Putty from a windows box.
default shell /bin/csh 

i have also tried to change it to /bin/bash to see if it was an issue with the shell but they both have the same issue.
well they actually look the same but my .history file has changed to .bash_history now so i suspect the change worked. 

also typing which $SHELL will give the response  /bin/bash


----------



## SirDice (Feb 18, 2009)

It's probably a PuTTY setting. Most likely the character set translation.


----------



## cad (Feb 19, 2009)

Ok i tried some different translation for char sets in putty

they still come up the same 

I dont realy think it is putty translation because i have access to other linux boxes using the same putty and it displays the files properly. I should have also mentioned that it was ok the other day. 

I logged in on Mon and it was fine. I logged in on Tue and it looks like this.


total 28
drwxr-xr-x  6 user1  wheel  512 f 04:43 ?"??
drwxr-xr-x  6 user1  wheel  512 f 03:31 ?#??
-rw-r--r--  1 user1  wheel  767 f 03:31 ?$??
-rw-r--r--  1 user1  wheel  283 f 05:05 ?%??
-rw-r--r--  1 user1  wheel  158 f 03:31 ?&??
-rw-r--r--  1 user1  wheel  331 f 03:31 ?'??
-rw-r--r--  1 user1  wheel  797 f 03:31 ?(??
-rw-r--r--  1 user1  wheel  975 f 03:31 ?)??
-rw-------  1 user1  wheel  373 f 03:31 ?*??
-rw-------  1 user1  wheel  276 f 03:31 ?+??
drwxr-xr-x  2 user1  wheel  512 f 03:47 ?,??
drwxr-xr-x  3 user1  wheel  512 f 03:47 ?-??
drwx------  2 user1  wheel  512 f 03:43 ?.??
-r--------  1 user1  wheel    0 f 04:14 ?/??
drwxr-xr-x  3 user1  wheel  512 f 04:43 ?P??

instead of the usual
drwxr-xr-x    3 user1    wheel         512 Feb 15 04:43 .
drwxr-xr-x    6 user1    wheel         512 Feb 15 03:31 ..
-rw-r--r--    1 user1    wheel         767 Feb 15 03:31 .cshrc
-rw-r--r--    1 user1    wheel         283 Feb 17 05:05 .login
-rw-r--r--    1 user1    wheel         158 Feb 15 03:31 .login_conf
-rw-------    1 user1    wheel         373 Feb 15 03:31 .mail_aliases
-rw-r--r--    1 user1    wheel         331 Feb 15 03:31 .mailrc
-rw-r--r--    1 user1    wheel         797 Feb 15 03:31 .profile
-rw-------    1 user1    wheel         276 Feb 15 03:31 .rhosts
-rw-r--r--    1 user1    wheel         975 Feb 15 03:31 .shrc
drwx------    2 user1    wheel         512 Feb 15 03:43 .ssh
drwxr-xr-x    2 user1    wheel         512 Feb 15 03:47 tmp
drwxr-xr-x    3 user1    wheel         512 Feb 15 03:47 var

I think it is related to the box since i have tried a few charsets translations with putty and they have no all seem the same. Also since its not happening on other linuxboxes with the same putty I think its ruled out. 

Does any one know how to check "ls" with md5sum to see if it has been altered in any way or how to update only these files via command line.


----------



## Mel_Flynn (Feb 19, 2009)

Doesn't look like a character encoding and translation issue, since it would show for the date, permissions etc as well.
Possible option is CLICOLOR and LSCOLORS and bad translation through terminal settings. Somebody could've modified the environment, through /etc/login.conf, .login (good candidate looking at the date stamp), /etc/profile etc.
You can rule this out by looking at env for the above variables.


----------



## cad (Feb 19, 2009)

ok the setenv of /etc/login.conf
 :setenv=MAIL=/var/mail/$,BLOCKSIZE=K,FTP_PASSIVE_MODE=YES:\

set env in /etc/profile
ENV=$HOME/.shrc; export ENV

and the setenv in .cshrc
 setenv  EDITOR  vi
 setenv  PAGER   more
 setenv  BLOCKSIZE       K


Another test using tab to display the available files.
Heres the out put:

user1@pleki$ ls
H!??            H$??            ?!??            ?$??
H"??            H%??            ?"??            ?%??
H&??            ?#??            ?&??
user1@pleki$ vi .
./             .cshrc         .mail_aliases  .rhosts
../            .login         .mailrc        .shrc
.login_conf    .profile       .ssh/


the resent change to .login was due to trying to change to bash as the default shell as i thought it may have been an issue with csh shell.
I added this to .login:
[ -x /bin/bash ] && exec /bin/bash

=====================

after your reply i tried the following in .cshrc:
CLICOLOR="YES";    export CLICOLOR
LSCOLORS="ExGxFxdxCxDxDxhbadExEx";    export LSCOLORS
but i could not see the difference.


----------



## SirDice (Feb 19, 2009)

cad said:
			
		

> I added this to .login:
> [ -x /bin/bash ] && exec /bin/bash



Use the chsh command to change your shell.




> after your reply i tried the following in .cshrc:
> CLICOLOR="YES";    export CLICOLOR
> LSCOLORS="ExGxFxdxCxDxDxhbadExEx";    export LSCOLORS
> but i could not see the difference.


That's not correct for csh. Don't put bourne shell stuff in .cshrc


What's your TERM set to? Putty, by default, uses xterm.


----------



## Mel_Flynn (Feb 19, 2009)

tab expansion doesn't use ls, but you can confirm this is the problem by explicitly turning the coloring off.
Put in your .cshrc:
unsetenv CLICOLOR
unsetenv LSCOLORS

If things show up normal now, then your terminal settings don't mix. Then please provide the output of the env command. You can delete anything SSH_* but it's best to leave the rest in tact.


----------



## cad (Feb 20, 2009)

Quote: SirDice

I removed from .login
[ -x /bin/bash ] && exec /bin/bash

used command
chsh -s /bin/bash user1
updated successfully


removed from .cshrc:
CLICOLOR="YES"; export CLICOLOR
LSCOLORS="ExGxFxdxCxDxDxhbadExEx"; export LSCOLORS

checked which term
user1@pleki$ echo $TERM
xterm

thanks SirDice.


Quote:Mel_Flynn
Put in your .cshrc:
unsetenv CLICOLOR
unsetenv LSCOLORS

Ok done this. I then logged out then back in with no change
still getting:
user1@pleki$ ls
H!?? H$?? ?!?? ?$??
H"?? H%?? ?"?? ?%??
H&?? ?#?? ?&??

Im not sure which env command I should use or whether you were just referring to the unsetenv command?

Im unable to locate any files with SSH_*

one thing I also checked was the .profile of root. 
it has term set to TERM=${TERM:-cons25}
wondering if this could be the conflict. 

I had ruled it out since the file time stamp has not change since 2004

I tried to change the TERM=${TERM:-cons25} to TERM=$xterm 
Im not sure if that was correct but on logging to another session via ssh it didn't change anything either still having the same issue with the following output:
user1@pleki$ ls
H!?? H$?? ?!?? ?$??
H"?? H%?? ?"?? ?%??
H&?? ?#?? ?&??

id really like to thank you to for your support. Even though the reason has not been found it does seem we are ruling somethings out.


----------



## SirDice (Feb 20, 2009)

cad said:
			
		

> used command
> chsh -s /bin/bash user1
> updated successfully


Bash isn't part of the base OS so it lives in /usr/local/bin/.


----------



## Mel_Flynn (Feb 20, 2009)

Simply the env command:

```
$ env
KDE_MULTIHEAD=false
MM_CHARSET=UTF-8
DM_CONTROL=/var/run/xdmctl
SHELL=/usr/local/bin/bash
TERM=xterm
XDM_MANAGED=/var/run/xdmctl/xdmctl-:0,maysd,mayfn,sched,rsvd,method=classic
PACKAGESITE=http://packages-7:8050/
KDE_FULL_SESSION=true
PAGER=less -i -s -g
FTP_PASSIVE_MODE=YES
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/opt/sbin:/opt/bin:/home/mdev/bin
DESKTOP_SESSION=kde
BLOCKSIZE=M
EDITOR=vim
KDE_SESSION_UID=
LANG=en_US.UTF-8
PS1=\[\033[32m\]\u@\H  \[\033[33m\w\033[0m\]
\$
SHLVL=1
MAKEOBJDIRPREFIX=/home/mdev/obj
XCURSOR_THEME=default
XDG_DATA_DIRS=:/usr/share:/usr/local/share:/usr/local/share/gnome
DISPLAY=:0
COLORTERM=
_=/usr/bin/env
```


----------



## cad (Feb 21, 2009)

Quote:SirDice
There was a som link from /bin/bash to /usr/local/bin/bash but i changed it anyway.
chsh -s /usr/local/bin/bash user1


Quote:Mel_Flynn  	 Simply the env command:

insert blushing.gif 

env of user1

$ env
SHELL=/usr/local/bin/bash
TERM=xterm
USER=user1
PAGER=more
FTP_PASSIVE_MODE=YES
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/home/user1/bin
MAIL=/var/mail/user1
BLOCKSIZE=K
PWD=/home/user1
EDITOR=vi
SHLVL=1
HOME=/home/user1
LOGNAME=user1
_=/usr/bin/env

only the SSH has been removed
env of root

# env
TERM=xterm
SHELL=/usr/local/bin/bash
USER=user1
PAGER=more
FTP_PASSIVE_MODE=YES
MAIL=/var/mail/user1
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/home/user1/bin
_=/usr/bin/env
BLOCKSIZE=K
PWD=/home/user1
EDITOR=vi
HOME=/root
SHLVL=2
LOGNAME=user1


----------

