LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Does anybody have any experience on generating SSH key in Labview?

well, System Exec calls the Windows shell and not the cygwin shell. So what you probably want to do to really emulate what you do in your cygwin window is to explicitedly call the cygwin shell as first parameter tin you system exec call and append the rest as command line parameters for cygwin. Most likely you are running into a command line parameter substitution somewhere that the Windows shell does in Windows 7 that it didn't do in earlier Windows versions. While Microsoft usually expends a lot of effort trying to be backwards compatible they sometimes fail in that too ;-).

Rolf Kalbermatter
My Blog
0 Kudos
Message 11 of 17
(968 Views)

How do you call Cygwin shell in system exec.vi on Windows 7? If I just type cygwin in Start - search programs and files -- enter. I can bring up cygwin window. However, with Sytem exec.vi, I tried the same thing in the command line and nothing happened. Labview always gives me a "Memory Full" error. Does anyone have any experience on calling cygwin commands with System Exec.vi on Windows 7?

 

Thanks very much!

0 Kudos
Message 12 of 17
(955 Views)

Well sorry! I was in my previous post somewhat unprecise. System Exec doesn't call the Windows shell itself but simply instantiates a process using the Windows API call CreateProcess(). As such it does only do very limited command line processing. Specifically if the first parameter in the command line is not an absolute path the Windows kernel will only try to locate that program in the standard Windows search locations, namely:

 

  1. The directory from which the application loaded.
  2. The current directory for the parent process.
  3. The 32-bit Windows system directory. Use the GetSystemDirectory function to get the path of this directory.
  4. The 16-bit Windows system directory. There is no function that obtains the path of this directory, but it is searched. The name of this directory is System.
  5. The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
  6. The directories that are listed in the PATH environment variable. Note that this function does not search the per-application path specified by the App Paths registry key. To include this per-application path in the search sequence, use the ShellExecute function.

This means that your cygwin my not be found automatically because it is added to the registry. Adding the shell command line interpreter cmd as first parameter will call the Windows command line shell and makes additional functionality available that is implemented by the shell and not the Windows kernel.

Rolf Kalbermatter
My Blog
Message 13 of 17
(944 Views)

After I changed the Wait Until Completion? from defaulted True to False, I was able to bring up cygwin window. This is how I did it: I wired a constant of c:\cygwin\cygwin.bat to the command line in System Exec.vi and it brought up cygwin window.

Then I tried to change the constant to c:\cygwin\cygwin.bat ssh-keygen, and it didn't do anything besides bringing up cygwin window.

Please note: If I just mannually type ssh-keygen in cygwin window, it will start to generate ssh keys. So my question is that what do I need to send to the command line of system exec.vi to make the command ssh-keygen working here?

 

Thanks very much! 

0 Kudos
Message 14 of 17
(922 Views)

The System Exec VI can call external programs, but I don't believe there's a way to get the System Exec VI to control those external programs. Once you call the cygwin process, it's separate from LabVIEW and it's not easy to get the two to interact. 

 

If there's a way to execute your full command using one command line call, then you can programmatically control it with LabVIEW's System Exec VI. Otherwise you'll need to interface with an external DLL or something along those lines. You can use Call Library Function Node to call a DLL, and if you can write a DLL to call ssh-keygen on cygwin, then that will work fine.

 

 

 

 

Colden
0 Kudos
Message 15 of 17
(899 Views)

 


@djfasd wrote:

After I changed the Wait Until Completion? from defaulted True to False, I was able to bring up cygwin window. This is how I did it: I wired a constant of c:\cygwin\cygwin.bat to the command line in System Exec.vi and it brought up cygwin window.

Then I tried to change the constant to c:\cygwin\cygwin.bat ssh-keygen, and it didn't do anything besides bringing up cygwin window.

Please note: If I just mannually type ssh-keygen in cygwin window, it will start to generate ssh keys. So my question is that what do I need to send to the command line of system exec.vi to make the command ssh-keygen working here?

 

Thanks very much! 


I can't tell you a point for point solution here, but you have to consider what really happens when you execute that command using CreateProcess(). MSDN help to CreateProcess() could be also an interesting read, although it for sure won't cover the whole picture. Since your first parameter is an absolute path to the cygwin batch file, Windows doesn't have any problem to locate it and start it. Since it is a batch file it uses for that the batch file execution environment. That then gets the rest of the command line passed as new command parameter. Depending on how the batch file is written this could be already where it goes wrong. Does the batch file try to do any processing on the passed in parameters? If so it may be not able to do that correctly since the path to ssh-keygen isn't fully specified.

 

If it however simply passes the remaining parameters to the cygwin execeutable then cygwin itself probably has trouble to locate the ssh-keygen. When you open up cygwin you most likely move to the directory where ssh-keygen is located and when executing then "ssh-keygen", the current directory is the first one cygwin will check if it sees a relative filename. However when you start up cygwin through a command you either have to set the current directory using a specific command line option, or specify the fully qualified path to the cygwin program you want to execute. Otherwise cygwin has not way of knowing where to look for ssh-keygen.

 

And beware that path parameters that need to be passed to cygwin, may need to follow a different syntax than what is normal on Windows, and in order to specify them in Windows without trouble you may need to quote them or something.

 

Rolf Kalbermatter
My Blog
0 Kudos
Message 16 of 17
(890 Views)

With the help of NI application engineers, it was found that the following worked:

command line -- c:\cygwin\Cygwin.bat

standard input -- ssh-keygen -q -b 1024 -t rsa -f newoutput_keyfile -N ''

wait until completion? -- T

 

On XP and Win 7 Enterprise, the working directory doesn't set the destination of the keys generated if you do it this way. The keys go to differrent places on XP and Win 7 that user has no control.

 

On the other hand, on XP, if you just send the ssh-keygen command to the command line directly and nothing to standard input, it also works and you can set the destination of the keys to the working directory of System Exec.vi that you specify.

 

I was just trying to share what I had experienced to those who might be interested and might find this helpful.

 

Thank you all for looking at this issue for me. I really appreciated it!

 

Regards.

0 Kudos
Message 17 of 17
(871 Views)