Although the content is written to the Log.txt file, I am not allowed to open the file while the process is running. It would be useful if I could process this information while the Runtime Utility Center process is running.
Hello,
Thank you for the quick help. However, I have noticed a very strange behavior. When I enter the command directly into CMD or Start a .bat File, I get the desired output inside the CMD Window.
But through Python, I don’t get any output at all.
However, when I start the working batch file inside an batch file and want to write the output to a output.txt file for testing purposes, only the sent command is displayed but not the logs itself.
call Timeout > output.txt 2>&1
does not work, and i think this is the reason why i don’t get anything in python either
I am starting to think this would need some arguments on the Python subprocess.run() function call to get the desired output. Specifically stdout and stderr and capture_output.
That’s absolutely correct and it works perfectly fine with other programs. Only with the RUC, I don’t get any output, but only a return value.
For example:
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, shell=True)
print(result.returncode, result.stdout, result.stderr)
result = subprocess.run(command, shell=True, capture_output=True, universal_newlines=True)
print(result.returncode, result.stdout, result.stderr)
with subprocess.Popen(command, stdout=subprocess.PIPE, shell=True, text=True) as p:
print("PID: " + p.pid.__str__())
for line in p.stdout:
print("O =: ",line)
I have already tried all possible arguments and set them to true/false.
I think I am not getting any output for the same reason I tried to explain in the previous post, which is that a batch file cannot catch the output either.
I can confirm that I’m also not able to redirect the -consoleOutput data to a file by the common way using ‘>’ (I tried different ways of redirection including starting a new cmd instance by calling cmd.exe /c “your command” and so on, but I also haven’t found a possibility - I haven’t tested anything with Python because already using batch files showed that behavior).
I’ve no idea what’s the reason behind, but it seems a bit like that the output is not delivered trough stdout or stderr, or that it can’t be redirected because of the output coding (for example as I know, UTF8 encoded data cannot be redirected on the console), but that’s just a guess.
I recommend to inform your local B&R support team about the behavior, so that they can check with RnD what’s the reason for and if the’re possibilities to realize your wanted functionality.