Xojo Shell on Raspberry Pi

Hello All,

I have a shell and can send a command to my PI, although I know this is not a specific PI topic.

What I don’t understand is that once a command is sent I am unable to send another to the same opened shell unless I close the shell.

What am I doing wrong, presuming the question is correct.

How am I able to determine, apart from parsing the returned data, when a current sequence is complete, in order to close it for the next process.

I notice a process ends with a $ sign on its own line, is this constant and able to be guaranteed as a determination of end of sequence character.

Regards

Mark

You need a loop for this. Cause you open a console application, which has no main thread.

There is an example from xojo you could use to understand how it works.

You can put several commands on the same line separated by semicolon. For instance

cd Desktop ; ls

Note that Xojo shell under Linux always starts in home. I also noted that it was better to add a space on each side of the semicolon.

You can also create a bash script and execute it if you want to do many commands or conditional statements.

Don’t forget to chmod 755 the bash script before you call it.

That’s a personal preference.

Not necessarily. On Mac, cd/; ls does not actually cd unless there is a space before the semicolon.

Your syntax is malformed.

Cosmo:~ tim$ cd /; ls Applications etc Developer home Library installer.failurerequests Network net System opt Users private Volumes sbin bin tmp cores usr dev var Cosmo:/ tim$

cd /;ls will also work.

What mode are you using on the shell. You should be able to reuse the shell.

Hello Tim,
Its an interactive shell mode 2.
I test with ifconfig, send it, the window shows the data and then I can not send another command.
this is using the sample of the interactive shell that ships with Xojo completely unmodified.

It works fine on the Mac, but not on the PI.

Try this…
A && B Run B if A succeeded

cd /applications && ls

A || B Run B if A failed

cd applicats || ls

I changed the channel and title for this topic as it appears to be an issue only on the PI from my own testing.

OK now I tested in Linux, Mint 17.3, and the same issue, the second issue of the command is not acted upon, basically nothing happens.

It appears this is a Linux issue and not PI as such.

Results are with R15.4.1 and latest B16…

Are you issuing the initial command with Execute and the rest of the commands with WriteLine?

I am using the supplied example from examples>advanced>shell>Interactive Shell.xojo_binary_project

completely unmodified.

this is what sends the data:-

  If Key = Chr(13) Then
    If Not mShell.IsRunning Then
      #If TargetWin32 Then
        mShell.Execute(InputField.Text)
      #Else
        mShell.Execute("sh")
      #Endif
    End If
    
    mShell.Write(InputField.Text)
    mShell.Write(Chr(13))
    InputField.Text = ""
    Return True
  Else
    Return False
  End If

which appears to be completely correct to my limited knowledge.

Although it does not use WriteLine it is obviously adding the required return character separately.

As mentioned, no issues at all on the Mac, but PI and my Linux Mint VM do not accept the second command sent, there is simply nothing that occurs.

Replace chr(13) with chr(10) should help i think.

Writeline should use the correct line ending for the platform.

ok so changing the supplied examples code from this:-

mShell.Write(InputField.Text)
mShell.Write(Chr(13))

to this:-

mShell.WriteLine(InputField.Text)

Allows it to work properly on linux and on Mac.

Therefore this subject is concluded.

The next thing is how would it be recommended that this issue be reported, via a feedback case?

Thanks for all the input.

Did you try using
mShell.Write(InputField.Text)
mShell.Write(Chr(10)) // <<<<<<<<<<<<<< this is the correct Unix (linux & OS X) end of line

But I’d prefer using

mShell.Write(EndOfLine)

Hello Norman,

No I did not try exactly that, I was innocently assuming the supplied examples would work.

I have managed to ignore shell for decades as I find it a staggeringly unmoving method of communicating with an OS.
Unfortunately I have to interact in this uninspiring way now to deal with PI.

Because of this I have absolutely zero idea what the formation of data sent to a shell should comprise, and searching for any information gives me nothing that I find useful.

For instance I am entirely unable to find any search string in duck duck that would allow me to find out how the shell requires to be addressed.
I do not know where to seek the knowledge about the required end of line character, nor any other element of the shell requirements.

And I do not mean sending commands, I mean the actual control characters unseen by the user when using a shell, such as the 10 and 13 to end a command.

And that brings me to the question, why does the supplied example work perfectly well on my Mac when using mShell.Write(Chr(13))
but does not, as seems to be the correct behaviour, on a Linux system.

Should the provided example shipped with Xojo be modified to work on all platforms so as to avoid confusion for anyone coming to this method of OS interaction?

Regards

Mark

File a report against the docs/examples. It is a flawed example.

Thanks Tim.

I will do just that.

It seems from my observations that you are something of a knowledgeable user of the shell.

May I ask if the results I received from a command within the Xojo shell, such as “Verify password:” or “$” can be relied upon to be static and allow me to parse the data for users who are unable to determine what the results mean.

I basically wish to remove any of my users having to go through the process of dealing with terminal and use the Pi like they would expect to, that is a simple GUI interface.

Regards

Mark