Jump to content

System exec. issue.


Recommended Posts

Hi all,

Im strugeling with the "simple" issue. I call the python script with args via System exec.

If "wait until completion?" is TRUE, its no responding or just reports error. Error is that the script is missing args. If wait until completion? is FALSE, then script work just fine.

Commend line: "python.exe script.py --port com3 --adr 2 file_name.hex"

image.png.bcc90e8a38827e2b6727a1b77c648431.png

 

Im running LV 2019 32bit version.

 

Link to comment

HI.

Error cluster shows nothing, i meant "standart error output"

Script is upgrading FW on my PLC. I can see LED is togeling, and in the cmd window progress bar is changing during that process. When the process is over i  i can use "standart output" to veryfi the results. it can happend that the FW upgrade need to be repeeted. 

 

Link to comment

Standard error output can't show anything either when you make the wait for completion false. So that would not indicate anything. With wait for completion set to false the process is launched and forgotten by LabVIEW. If it runs a millisecond or infinitely doesn't matter for LabVIEW. It has long continued and that process may still be running, or may have died or normally terminated.

So the only thing that remains is:

Does the LED toggle anyhow and does it show some progress in the command window? If so then the only difference is that with wait for completion set to true LabVIEW will wait for the process to terminate and then copy the standard output and standard error information into the string indicators of that function. With wait for completion set to false LabVIEW will NOT connect the standard input, standard output and standard errors in any way and whatever your program writes to those either is shown on the command window or lost forever in the /dev/null world of computers.

Link to comment
8 hours ago, Daniel Bochen said:

...Error is that the script is missing args. If wait until completion? is FALSE, then script work just fine...

It sounds to me like the error is being generated by the Python script and isn't necessarily the SystemExec VI if it claims to be missing args.  As Rolf said, if you pass it a FALSE for Wait until Completion, LabVIEW will send the command and return immediately - not waiting for the python script to return.

Some things to remember, if your "script.py" or "file_name.hex" is a path or filename that has any spaces in it, you'll have to put the entire path or filename in quotes as I believe arguments are parsed by Python using spaces (Please correct me if I'm wrong, I don't know much about Python.):

python.exe "C:\path\to\script.py" --port com3 --adr 2 "C:\path\to\file_name.hex"

Alternatively, you could try passing the command switch to execute and then terminate:

cmd /C python.exe "C:\path\to\script.py" --port com3 --adr 2 "C:\path\to\file_name.hex"

If your python script is waiting for a response before returning to the command prompt, then SystemExec will hang forever waiting for a response.  In that case you'll have to pass a value to STDIN.  

We had an instance of executing an EXE via SystemExec that would wait for a "Press any key to continue" if it had an error and would hang forever waiting for a key press.  Our solution was to pass it a "space" constant for STDIN so that it would return.  Interestingly, it wouldn't return the error via STDERR and did so via STDOUT.

image.png.cd41671b0215deade3810a41b25e32a0.png

Edited by Bryan
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.