LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ssh another solution

Not a question but another solution to using ssh from LabVIEW.

 

TL;DR: Use Cygwin.

 

I have a need to have programs run on a different machine than the one I have LabVIEW on from LabVIEW. Initially I used PSTools to manage that but found them very slow. Searching for a better solution I came across Cygwin. Cygwin is a project that aims to deliver a "unix" like shell to windows. It is POSIX compliant and I have found it to work very well.

 

I am connecting to a Windows 7 machine so my procedure is to install Cygwin on both the LabVIEW machine and the "host" machine. On the host run through the process to setup and start a ssh server. From the LabVIEW machine open a Cygwin terminal and go through the process of exchanging keys with the Host so you can login without a password.

 

Once you can login to the host from the Cygwin terminal without passwords you are setup. From LabVIEW use the system exec VI to pass out the full path and command (Example: my Cygwin is installed in C:\Cygwin64, so, the string I pass into system exec looks like "C:\Cygwin64\bin\ssh username@hostname ls -al".) Any thing returned will be in the standard output string.

 

One of the benefits of using Cygwin is that you can have a full Bash shell running on the other side. Instead of long complicated strings of commands from LabVIEW you can put that complication in a script and just tell the host to run that script. It takes care of any directory changes and can massage the returned data to give LabVIEW just the interesting stuff.

 

I realize I've glossed over the details of installing Cygwin and setting up a ssh server but these are not germane to LabVIEW and there are plenty of resources available to guide you through that (the only warning I have is that permissions are tricky and must be set correctly for this to work; on sshd "-vvv" is your friend.) The LabVIEW VI is trivial once you have the rest working, just pass in the string like I put above and look for the output.

 

Ideally one should be able to start an ssh session at the beginning of the test and then be able send commands when ever needed until the end of the test. That would save a couple hundred mS per call. I haven't worked that out yet.

 

Dirk

0 Kudos
Message 1 of 1
(3,005 Views)