Not Receiving All Data From Query
TRosier opened this issue · 11 comments
There is a small program that we are running on a Linux server. When logged using Putty the output is shown below:
..# ./dump_burst -p 3305 -d eth1 -c g -n 1
FILTER STR udp port 3305 and ip[39] & 0x1 == 1
TIME BT MO SP MB CRC NCR-MSB NCR-LSB IGID INID SNUM SYMRATE SNR SNR(dB) FREQOFF TIMING 0xHDLC KA
---- -- -- -- -- --- ------- ------- ---- ---- ---- ------- --- --- ------- ------ ---- --
00000012 TD 8 00 00 001 0x00000338 0x7ed7b208 0001 0004 0x0f52 04000000 0x1b9c18d0 13.7253 -0000061 -0000001 0x8004 1
Did not match got ./dump_burst expected dump_burst**_****
When we use the ssh2 VIs below this is all we are getting :
FILTER STR udp port 3305 and ip[39] & 0x1 == 1
Did not match got ./dump_burst expected dump_burst
We are getting the first and last lines of the output. At first I thought it may be a superuser issue but running in Putty w/o being in superuser mode give the same type of output showing the missing data when using the ssh2 VIs. Not all the data is there but there is still some between the fist and last lines. That is shown below.
$ ./dump_burst -p 3305 -d eth1 -c g -n1
FILTER STR udp port 3305 and ip[39] & 0x1 == 1
TIME BT MO SP MB CRC NCR-MSB NCR-LSB IGID INID SNUM SYMRATE SNR SNR(dB) FREQOFF TIMING 0xHDLC KA
---- -- -- -- -- --- ------- ------- ---- ---- ---- ------- --- --- ------- ------ ---- --
Couldn't open device eth1: socket: Operation not permitted
Did not match got ./dump_burst expected dump_burst
Any help with this would be appreciated.
Can you please share a simplified VI snippet that recreates the issue?
My guess is that you need to use the Write Terminal.vi and specify a terminal.
These kinds of issues arise because PuTTY is establishing a terminal channel and a shell into the remote system. This means a lot of the environment and "plumbing" is handled implicitly by PuTTY. In contrast, this Toolkit is a low-level toolkit that minimizes any implicit actions. The toolkit is also for programmatic access, not necessarily an interactive shell.
Have you tried the Read-Execute-Print-Loop with a Raspberry Pi.vi example? Despite the name, any remote SSH server can be used. It does not need to be a Raspberry Pi.
Thank you for the response.
I believe I have attached the snippet you requested. I have not had a chance to look at https://github.com/fieldrndservices/libssh2-labview/blob/main/src/Examples/Read-Execute-Print-Loop%20with%20a%20Raspberry%20Pi.vi, however I will take a look at it soon.
I downloaded the VI. There are a lot of VIs that the main one cannot find. I believe they are SSH VIs and I have the SSH2 package installed.
I believe I have attached the snippet you requested.
I do not see any VI snippet in the comments for this issue. Can you please try again?
I downloaded the VI. There are a lot of VIs that the main one cannot find. I believe they are SSH VIs and I have the SSH2 package installed.
The VI is provided as an Example in the Example Finder within the LabVIEW development environment. I just provided a link to the VI in the repository for reference. If you have installed the package, then the example VI should be available within the development environment.
Hi Chris,
So I have the output of the command from Putty...
./dump_burst -p 3305 -d eth1 -c g -n 1
FILTER STR udp port 3305 and ip[39] & 0x1 == 1
TIME BT MO SP MB CRC NCR-MSB NCR-LSB IGID INID SNUM SYMRATE SNR SNR(dB) FREQOFF TIMING 0xHDLC KA
00000012 TD 8 00 00 001 0x00000338 0x7ed7b208 0001 0004 0x0f52 04000000 0x1b9c18d0 13.7253 -0000061 -0000001 0x8004 1
Did not match got ./dump_burst expected dump_burst
Then I have the output from the VI you referenced...
So I am getting the same thing from the Read-Execute...VI that I am from the VI I am using initially. The first and last lines are returned and the data needed in the middle is not.
I wonder if the data in the middle is on STDERR instead of STDOUT? Your VI and the example are only reading STDOUT. Can you try adding reading STDERR?
PuTTY, and most terminals/shells, will "mix" STDOUT and STDERR writing to the terminal.
So that did it, the missing data is being sent on STDERR. So thank you for the help with that. I appreciate it. One piece left is I have to read this after logging in as super user. That requires a login then sending a su - and another pw. I remember there is a way to send multiple command but not sure how to do it. Any advice for that?
OK so I have all of this figured out now. I searched and found #5 which I used as a reference. I can now log on and invoke super user mode. From there I can run the command and get the expected output. The only thing that is strange and I was trying understand why, is that there was no output in this case with STDERR. I had to put the READ back in place and then remove the ./ from the ./dump_burst -p 3305 -d eth1 -c g -n 1 command. I can share a snippet of the block diagram if you're interested. Otherwise, I appreciate the help and this issue can be closed.
Great! I am glad you were able to resolve all of your issues. Please share the block diagram so others that may encounter a similar issue in the future will benefit. Thank you.
No output on STDERR might be unrelated to this toolkit and related to executing commands in a superuser subshell, su -u
. STDERR might need to be manually redirected to the terminal or parent shell when using a superuser sub-shell.