Cannot get shell result to show in a text area

Hello.

I am trying to get the results of a shell inquiry to show up in a text area. Other commands do work, but this one is giving me fits. Any ideas what I am doing wrong?

dim sh As new Shell
sh.Execute(“cat /proc/device-tree/model”)
dim s as string = sh.ReadAll
outputArea.AppendText(s)
msgbox s

The message box displays the correct info, so I know that S contains the answer. I just cannot get it to display inthe text area.

Thanks,
Tim

Why not use TextInputStream? Is it related to control drawing, does outputArea.Refresh have any effect? Is it related to timing, does an event driven design work?

Hi Tim,
OutPutArea.refresh has not effect

The shell holds the data. It is being read, as shown when the msgbox displays the contents of S. For some reason I cannot get the contents to display in the text area…

For this code, you select a radiobutton, then click a pushbutton which has the code for the radiobutton selected. Other commands work fine:

dim sh As new Shell
#If TargetLinux Then
sh.Execute(“uname -a”)

#ElseIf TargetWindows Then
mshell.Execute(“net start AxcysClientService”)
msgbox “available for Linux only”
Return
#Endif

If sh.ErrorCode = 0 Then
//OutputArea.AppendText("…")
OutputArea.AppendText(sh.Result)
Else
MsgBox "An error occurred " + cstr(sh.ErrorCode)
End If

Yes, and cat is for reading a file into stdout, so why the overhead of an additional process when you could just TextInputStream?

Still wondering if event driven (DataAvailable) has any effect. Have you checked the contents of the string variable for invisible characters?

How would you use TextInputStream?

Have not checked for invisible characters. Is there a best use method for that?

// The following was written in the post editor and may need corrections
var fTarget as new FolderItem("/proc/device-tree/model", FolderItem.PathModes.Native)
var tis as TextInputStream = TextInputStream.Open(fTarget)
dim sContents as String = tis.ReadAll
tis.Close

For invisible chars: You’d see things in the binary version of the string in the debugger that aren’t visible as text.

Interesting, if I push s to a textfield, it works perfectly.

Only issue is the textarea…
Tim

That kind of makes it sound more like an invisible/control character issue, but I hope the TextInputStream example was useful.

I’m looking at it now Tim,

Is there an equally elegant way to check for unprintable/invisible characters?
Thank you!

Anything less than ASCII 32, 127 and 255 will probably be the issue, but my suspicion is that it’s simply chrb(0) that’s the issue. Strings from other sources often have nulls in them or at the end and cause these types of issues.

Try this, where s is your string.

s = s.ReplaceAll(chrb(0), "")
1 Like

Thanks Greg,
This code you suggested worked and fixed the problem!

Tim