fieldrndservices/libssh2-labview

read prompt message

rdp137 opened this issue · 8 comments

Is there anyway to read the prompt message during a read?

@rdp137 Can you please clarify by "prompt message"? Do you want to read the <user>@<host>/~$: portion found in shells? This is known as the "prompt", but there is also the "splash" or "welcome" message, which the series of text that is sent from a remote SSH server to the client after successfully establishing an authenticated connection and creating a shell. Typically, on first login from a command line SSH client, there is the splash message followed by the prompt.

Yes I need the @/~$: Basically, I use it to know that the remote system has completed its last command and is ready for the next. Maybe there is a better way. I do already see the splash message

@rdp137 I believe you will need to create a Shell sub-system channel and request a pseudo-teletype (pty) terminal for the channel to create an interactive session that will read the prompt from the remote SSH server. This is accomplished with the Shell.vi and the Write Terminal.vi in the LabVIEW toolkit. Creating a Shell channel will establish the STDERR, STDIN, and STDOUT streams. The prompt will be written to the STDOUT stream by the remote SSH server...I believe.

The Read-Execute-Print-Loop with a Raspberry Pi example will be a good starting point as it already demonstrates creating a shell channel connection and reading/writing. I believe all that is missing is using the Write Terminal.vi after using the Shell.vi. Note, the remote SSH server does not need to be a Raspberry Pi. It is just the most common request from users of this toolkit to connect to a Raspberry Pi over SSH.

when I add a Write Terminal.vi after the shell.vi I get an error. Error code -8125, channel request denied error.

Any ideas?

@rdp137 My guess is that the terminal you selected for the Write Terminal.vi was not supported by the remote SSH server. From the enum, which terminal type did you use?

According to the libssh2_channel_process_startup documentation, there is no information or details about a LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED error. So, not much help and the terminal type is my guess.

However, I may have switched the order and the Write Terminal.vi should be before the Shell.vi. See the ssh2.c example. They have the libssh2_channel_request_pty function, which is the same as the Write Terminal.vi, before the libssh2_channel_shell function. They also use a vanilla terminal.

@rdp137 Have you had a chance to work on this? Were you able to eventually read the prompt message?

Hi,
I can confirm that this was working
image

image

@Clio75 Great! Thanks for confirming. I will close this issue.