Starting Runtime Utility Center in silent and get more Information while in running

Hello,
I want to start the Runtime Utility Center via Python using subprocess and use the “silent” argument to start any .pil files.

For example, with the following command: strCommandLine = “C:\BrAutomation\Pvi\Tools\PVITransfer\PviTransfer.exe -silent C:\PIL\Test1.pil”

Everything works fine and I also receive a return value at the end of the process.

I wonder if it is possible to obtain the output text of the Runtime Utility Center, just like when started with “automatic” argument ?

For example:
ABLAUF GESTARTET: 22-05-2024, 10:52:58
1: @START@ “C:\XXX\Timeout.pil”
2: OnErrorResume
OnErrorResume ERFOLGREICH
3: StartPviMan “LoadLocal”
StartPviMan “LoadLocal” ERFOLGREICH
4: Connection “/IF=tcpip /LOPO=11159 /SA=1”, “/RT=1000 /AM=* /SDT=5 /DAIP=xxx.xxx.xxx.xxx /REPO=11159 /ANSL=1 /PT=11169”
Connection “/IF=tcpip /LOPO=11159 /SA=1”, “/RT=1000 /AM=* /SDT=5 /DAIP=xxx.xxx.xxx.xxx/REPO=11159 /ANSL=1 /PT=11169” ERFOLGREICH
5: WriteVariable “xxx\xxx”, “BOOL”, “1”
WriteVariable “xxx\xxx”, “BOOL”, “1” ERFOLGREICH
6: @END@ “C:\XXX\Timeout.pil”
ABLAUF FERTIG (ERFOLGREICH): 22-05-2024, 10:53:00

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.

You could try the -consoleOutput argument.

1 Like

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.

Example:

  1. CMD.exe: C:\\..\\PVITransfer.exe -silent -consoleOutput C:\\...\\Timeout.pil

  2. Batch File:%~dp0executable\PVITransfer.exe -silent -consoleOutput %~dp0Timeout.pil

works fine.

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.

  1. 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 would appreciate any possible solutions.

I would appreciate any possible solutions.

if you just need to set a variable via PVI you can probably use this wrapper instead:

https://hilch.github.io/Pvi.py/

I am familiar with the Pvi.py library. I need the RUC command “transfer to the target system”, to install new software.

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.

There are also options to get the exit codes by checking the returned subprocess.CompletedProcess object.

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.

Hi Alexander,

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.

Best regards!

Thank you for verifying. It seems plausible that the output is not being sent in binary. I will contact the B&R support team the week after next.

1 Like