[ProcessLibrary] Log result from PowerShell command

Hello everyone,

I use a PowerShell command in RobotFramework, and I want to send the result of my command in a file.

I added " > myfile.txt" in the end of my command, there is no problem when I do it manually, my file is created with the good result inside.

But when I run this same command in RobotFramework, my file is created but empty

Can anyone help me please?

Thank you!

Hi @Brahim1991,

Are you are using Run Process? If so, you probably want to not use > myfile.txt but rather stdout=myfile.txt (see the Process configuration link in Run Process help). if you don’t actually need the result in a file, just need to test the output you might want to look at ${result.stdout} also mentioned in the documentation.

Otherwise can you show us what your trying to do so we can guide you better.

Dave.

:frowning: quote=“damies13, post:2, topic:5352”]
stdout
[/quote]

Hi @damies13 , and than you for your response.

Yes I use Run Process as this :

Run Process Powershell.exe -Command [convert]::ToBase64String((Get-Content -path “C:\Users\BB\PycharmProjects\pythonProject\resources\xml\String_Linearise_01.txt” -Encoding byte)) stdout=encoded.txt #shell=true

I also tried without commenting shell=true, in the two cases my file is created bt empty :frowning:

I found a solution : I created a .ps1 file with my command inside, and I call it from RobotFramework as :

run process Powershell.exe ${CURDIR}${/}b64.ps1

Thank you for your help :slight_smile:

1 Like