LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sending 'scp' through System Exec.vi

Solved!
Go to solution

I need to send scp as a command through system exec.vi. 

 

If I open up command prompt and type scp it works fine.

If I hit the windows key and type run then type cmd.exe "/k scp" it works just fine as well

When I put cmd.exe "/k scp" in the Command Line input for System Exec.vi it returns 'scp"' is not recognized as an internal or external command,
operable program or batch file.

 

Any reason why this is different?  I was always under the assumption that if you can type it in Run then it should work just fine in the Command Line input.

 

Thoughts?

 

Thanks,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 1 of 12
(5,635 Views)

Try:

 

cmd /k scp

Tim
GHSP
Message 2 of 12
(5,609 Views)

I've tried every combination of quotes and non-quotes.  I've also tried batch file.  No dice.

 

My guess is application spacing issue?

 

Thanks,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 3 of 12
(5,606 Views)

when I type scp in a cmd prompt, I get a usage msg warning...

 

Frozen_0-1583954248361.png

 

Also, I believe the issue you are having is that you are not in the correct directory. Try including the full path to the exe in the system exec.
Alternatively, you could set the working directory to the scp exe path.

---------------------------------------------
Certified LabVIEW Developer (CLD)
There are two ways to tell somebody thanks: Kudos and Marked Solutions
0 Kudos
Message 4 of 12
(5,592 Views)

Directory doesn't matter.  Also, I can't start in the same directory as the executable because for some reason it gets installed in a different location on every PC when you install SSH.

 

My question really is:  Why does it work from Run but not from System Exec.vi?

 

Thanks for the response.

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 5 of 12
(5,584 Views)

I'm pretty sure you have to include the path.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 6 of 12
(5,557 Views)

Since the response says "not recognized as an internal or external command" indicates that the command cannot be found which would imply that the PATH environment variable is somehow different in LabVIEW vs Windows. Hence my suggestion about supplying the full path to your install of scp.

I have no further ideas. Sorry.

---------------------------------------------
Certified LabVIEW Developer (CLD)
There are two ways to tell somebody thanks: Kudos and Marked Solutions
Message 7 of 12
(5,552 Views)
Solution
Accepted by topic author ~jiggawax~

The path I have scp installed at is "C:\Windows\System32\OpenSSH\scp.exe".

 

I initially noticed that this was part of the system path, but not my user path, so I tried adding it to my user path and restarting LabVIEW. No dice.

Using "cmd /c echo %PATH%" did show me a path including the OpenSSH directory though...

 

Setting the working directory to C:\Windows\System32\OpenSSH gave me a new error - 267. Some googling tells me this indicates an invalid directory... peculiar, because it's obviously there. Lots of the links talk about running a process as another user (perhaps LabVIEW is doing something like this?)

 

Copying the scp.exe to my desktop and setting the working directory there produced the expected output for cmd /s /c "scp /?". The /s is presumably doing nothing in this simple case.

 

You said your exe installs to different locations on different computers - does it work with any? Are they all in System32?

 

If they are, I'd strongly suggest checking this: Command Not Recognized When Using System Exec VI (even if not, it's worth a look). This talks about the mapping done by Windows when running a 32-bit process (e.g. LabVIEW 32-bit) on a 64-bit OS with regards to system directories.

 

Following the guidance there, I got the response expected from a working directory of "." and command cmd /c C:\Windows\Sysnative\OpenSSH\scp /?. (but you still need the path).


GCentral
Message 8 of 12
(5,529 Views)

Thank you cbutcher.  That did the trick.  I had stumbled upon that in stack overflow for batch files but wasn't sure how to apply it to sysexec.

 

We will just force OpenSSH to be installed on our deployed machines.  Then we can use this path.

 

Regards,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 9 of 12
(5,482 Views)

Hi Jigg,
did you use it for TestStand? 
If yes, did you have some trouble with the password?
Because my usecase  is "only" reading a file from a linux-system to my TestStand-Windows based environment.
CMD TX: scp username@ipaddress:/home/hello.txt c:\temp\world.txt  
CMD RX: username@ipaddress's password:
CMD TX: sending the password (as line or append \n) then on RX side nothing happens. - quite bad....

Best regards
Juergen

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 10 of 12
(3,640 Views)