-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SSH cmd sending and receiving #3
Comments
Since libssh2-labview is a wrapper around the libssh2 C library, but with a C "adapter" library to make the libssh2 library more LabVIEW-friendly, the examples for the libssh2 library can be helpful. There is the ssh2_echo.c and ssh2_exec.c examples that can act as a guide for reading the response from a command over SSH. However, I recognize the examples are a little low-level, and written in C, which is sometimes difficult to reason about and/or maybe unfamiliar. Unfortunately, I do not currently have an example in LabVIEW for each of the libssh2 C library examples, which would be the most helpful. The current examples focus on SFTP, which was the main functionality needed by another collaborate at the initiation of this project. I will create a feature request/issue to add more examples. There is the Channel.lvlcass:Read All.vi from the Channel "class". This is probably the VI you want to use after executing the command. It encapsulates a lot of the reading functionality that appears in the C echo and execute examples. Here is a totally untested VI snippet that might work: |
I have created #4 to track creation of examples. Please let me know if the above VI snippet works and would be a good example. |
I will test and give you feedback shortly :) |
The Close.vi should be Destroy.vi. In the toolkit, for every Create there is a Destroy and for every Open (sometimes buried within a Create or Initialize VI) there is a Close VI. The wrong VI appeared to be used in this palette. Please see the attached ZIP/VIP with the updated palette that contains the missing Destroy.vi. However, my example should be amended to include using the Close.vi in addition to the Destroy.vi. Here is an updated VI snippet, still untested, and might work: |
Perfect 💃 🥇 |
Just a comment: |
I agree, and I have a vague reconcolation not really like this inconsistency within the API for the channels, but there appears to be some occasions where the channel does not always need to be closed, but it does always need to be destroyed, a.k.a. freed. Looking at the examples for the libssh2 library, only the ssh2.c, ssh2_agent.c, ssh2_echo, and ssh2_exec.c examples explicitly use the All of the examples use a variant of the A possible complication, if you look at the VI snippet in the README for uploading a file to a remote SSH server, there is the Close Channel and Wait on Close Channel VIs. So, how would including the Close VI in with the Destroy VI work if the user of the toolkit wanted to wait for the close signal to be received before destroying the channel? Basically, the inconsistency is a result of the libssh2 implementation and trying to create an ergonomic wrapper between C and LabVIEW. There is an Open and Close functions within the libssh2 library, but the Open is "morphed" into the Create functionality for the adapter library and the LabVIEW toolkit. I think technically the Close is not actually needed, but good practice. I also think that always executing a Close when the channel is destroyed may not hurt as well. This is all probably way more information than you want or need, but I am going to create a separate issue to track resolution of this inconsistency, which does annoy me, too. |
See Issue #6 for tracking the inconsistent naming. I believe this issue has been resolved. |
Hi,
I'm trying to use this toolkit to send and received cmd over ssh. I'm find the Execute that sending CMD. but how to received the answer ?
Great toolkit :D Looking forward to test it more
The text was updated successfully, but these errors were encountered: