LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can connect to plink from System Exec but can't send the next command

As one can see from the attached screenshot my first frame works just fine to call plink and login. It gives me the terminal window at the top. The problem comes when trying to send the 2nd command in the 2nd frame. It doesn't write it to the above plink terminal window. Can anyone please point out to me how I am miss using the second frame?

0 Kudos
Message 1 of 14
(4,685 Views)

Hi Jeffrey,

 

Your code is a little difficult to read as I cannot see exactly where each wire is connected.  A good practice is to never hide any section of a wire by another obect such as another wire, a control / indicator, or function (sub-VI).

 

Question:  why are you setting the "wait until completion" to False?  Are you not expecting a response from the "cmd /k plink ... " command?

 

Because of the hidden wire, I cannot tell what actually goes to the standard input, or if it is even necessary.  You should wire errour out 4 to the error in of the next System Exec and get rid of Error In 3.  The use of a Flat Sequence Structure is a bad idea as it may not help you with the sequencing of the code.

0 Kudos
Message 2 of 14
(4,678 Views)

Thanks for replying Ray. I agree with your coding practice. I was just throwing this together and trying to get it working without worrying about placement but you bring up a good point. 

I just had that set to false so I could debug and watch the commands in the window. 

 

At this point, no, I am just trying to get the commands to go one way. I figured I would try that next maybe when get this part working. 

 

Yes, all the programming is bad, i am just trying quick and dirty to see if I can get it to work. Yes the errors can and should be linked that way but i don't think that is the problem. 

 

Took a new screenshot for you. See attached. 

 

Thanks,

Jeff

0 Kudos
Message 3 of 14
(4,674 Views)

It seems like the system exec is writing to a new cmd window, not the opened and existing plink cmd window the first frame creates and connects to. I have tried &, &&, |& and || to and the commands together after the connection string in the first frame but that doesn't work either. 

0 Kudos
Message 4 of 14
(4,661 Views)

Try setting the System Exec's "wait until completion" to TRUE. Remove the wire that goes to the standrard input of the 2nd System Exec. Wire the outputs of both standard outputs to two seperate string indicators. The 2nd System Exec should also have the "wait until completion" set to TRUE. Wire the error out of the first System Exec to the error in of the 2nd System Exec. You can monitor if there is an error on the wire between the two System Execs using a probe.

 

Let us know the outputs of both System Execs and the error out info from the probe.

 

The space below the command seems to indicate that there is a carriage return '\n'.  Can you confirm that there is indeed a carriage return.

 

Why are you using a loop?  The poor System Exec is probably sending more requests to the plink than it can handle.  Can you remove the While loop and just execute as a single set of commands?  At least to debug the code.  

 

You may not need to provide the "C:\" as the working directory, but I doubt that it is causing you any issues.

 

Just a curiosity question:  DO you need to actually use plink to send the command over telnet / SSH?  Could you use native functions within LabVIEW?  Which version of LabVIEW are you using?

 

**** EDIT ****

 

I just realized something!  When using the first plink command (which probably works), it logs into a session.  However, that session is lost when you send the next command, because it does not have a reference to the session that you opened with the first command.  That means you may not be able to use plink as your solution to send Putty-like instructions at the command prompt.  You will most likely need to use native LabVIEW functions for Ethernet communication.

0 Kudos
Message 5 of 14
(4,635 Views)

If you are using LabVIEW 2012 (maybe 2013) or older, you can install the Internet Toolkit which has the telnet support.  I think you could select the appropriate port for SSH (I forget... it's been a while).

 

However, you can use VISA TCP.  The native functions uses a basic low level VISA Open to open a TCP connection to the appropriate port and IP address.  You can use the native VISA Read  & Write functions.   

 

0 Kudos
Message 6 of 14
(4,627 Views)

I just realized something!  When using the first plink command (which probably works), it logs into a session.  However, that session is lost when you send the next command, because it does not have a reference to the session that you opened with the first command.  That means you may not be able to use plink as your solution to send Putty-like instructions at the command prompt.  You will most likely need to use native LabVIEW functions for Ethernet communication.

 

Yes!!! That is what is happening. I am using Labview 2014 and will start trying the things you mentioned in your last post this AM and post back.

0 Kudos
Message 7 of 14
(4,603 Views)

In 2014 or Labview 2015, where is the internet toolkit? Some links say it has been discontinued maybe and added in directly? 

 

Are the VIs under data communication > protocols >TCP the ones you were thinking i can use to ssh?

0 Kudos
Message 8 of 14
(4,594 Views)

Which read and writes should I be using? The visa ones or the tcp ones shown in the attached pic?

0 Kudos
Message 9 of 14
(4,590 Views)

So i setup an alias Pi as a network connection in NI-MAX. It says OK on error out after I connect but I am not quite sure on how my string command vs ssh commands work. This doesn't do anything but it runs lol

0 Kudos
Message 10 of 14
(4,588 Views)