Some examples that I came across only call this method once, but I found that some data is then missed. I have had to play around with the number of iterations of the for loop as different tasks take different amounts of time. In the readReader() method, I monitor the DataAvailable flag. I have left this out of the class and leave it up to the application to do the reading. There is one more step that needs to be taken and that is to read the StreamReader object for responses from the client. The class only contains these three methods. The disconnect() method closes the session and disconnects from the client. Once the string has been written, the buffer is flushed. Public void executeCommand(string command) The execute command methods writes a string to the StreamWriter object. Once these references are created, they are stored in public properties. SshClient.Connect() //connect to the client SshClient = new SshClient(remote, user, password) StreamWriter – use this object to write to the remote client.StreamReader – this will be used to read what is returned from the client.SshClient – used to connect and disconnect from the client.You need to create the following objects that will be used by the various parts of the application. There are still a few features that I want to add but will leave them for another time. I decided to put everything into a class so that I can add to it in the future. All that I needed my library to do was connect to a remote client, execute commands and return the response and then disconnect when finished. (All good so far)Īs the library is massive, my plan of action was to use the library to write my own C# dll that would do what I wanted it to do. It is still actively supported and the latest version is only a few months old. I did find a really good C# library that looked like it would work. I did a bit of searching and didn’t come across any LabVIEW solutions that suited my needs. This method will also not work if you need to run custom applications on the remote client where the session needs to stay in memory. This is not very efficient as each time this method runs, it will log in to a different session before executing the command. If you want the response from each command, then you will need to call this method for each command. This works well when you want to execute a list of commands and are not interested in the response from each command.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |