How to get rid of control chars when using Korn sh (wodSSH / wodSSH.NET)
Hello.
I'm having trouble using wodSSH with the ksh shell (Korn shell). It is set on our customer's machine and it's hard or impossible to change shell settings there.
When I send some long command (in the example below it is a sequence of echo ) I get the output like this:
echo 123;echo 123;echo 123;echo 123;echo 123;echo 123;ech<#13>cho 123;echo 123;echo 123;echo 123;ech <<#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8><#8>o 123 <#13><#13><#10><#13><#10>123<#13><#10>123<#13><#10>123<#13><#10>123<#13><#10>123<#13><#10>123<#13><#10>123<#13><#10>$
I've replaced all ASCII control chars with <#N> .
When I enter long command in Putty for example I see that the shell is wrapping lines so that only the last several chars are visible and puts some spaces and < in the end of the line. Seems that when I use wodSSH I get the same sequence of characters. The terminal is adding and
characters to format the output properly. I'm trying to get rid of these control chars while do not corrupt the output. What I have tried:
1. Setting SSH object properties before connecting (some of them or all together):
ssh_.StripANSI = true;
ssh_.Columns = 1000;
ssh_.TerminalType = tty ; // (or dumb )
- nothing changed. I still get control chars.
2. Setting environment variable COLUMNS=1000 just after connecting. It helps on our local linux machine, but doesn't help on the customer's.
3. Trying to find out the logic and removing the garbage manually. I could do this for our local linux machine, but couldn't for the customer's.
Is there a way I can get the clear output?
Re: How to get rid of control chars when using Kor
Hi Virgoss,
I have tried to test it with our linux testing server and I didn't have any issue. It works as expected.
This is my code
[code]
Set ssh1 = New wodSSHCom
ssh1.HostName = hostname
ssh1.Blocking = True
ssh1.Protocol = SSH2
ssh1.Login = login
ssh1.Password = password
ssh1.StripANSI = True
ssh1.Connect
Dim command As String
command = echo 123;echo 123;echo 123;echo 123;echo 123;echo 123;echo 123;echo 123;echo 123;echo 123;echo 123;echo 123;echo 123;echo 123;echo 123;echo 123;echo
ssh1.WaitFor ( regex:[$ #>] $ )
Debug.Print ssh1.Execute(command + vbLf, ( regex:[$ #>] $ ))
ssh1.Disconnect
[/code]
Here is output I receive:
------------------------------------------------------
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
------------------------------------------------------
You are using wodSSH ActiveX component or wodSSH.NET component?
Any chance we can connect to your customers server and duplicate such issue? We will just connect few times and immediately disconnect.
You can send private information to techsupport@weonlydo.com
Let us know how it goes.
Regards,
Drazen