1

I need to run a python script on windows environment using powershell as an option only as my Bamboo Env will invoke that only.

I need powershell script which will call python script and should fail if python return status as 1. I'm not able to do so, can you please help me here.

1 Answer 1

2

Check $LASTEXITCODE automatic variable.

$LASTEXITCODE

Contains the exit code of the last Windows-based program that was run.

A sample Powershell script (apply . Dot sourcing operator to run a python script):

. py SomePythonScript.py
if ( $LASTEXITCODE -ne 0 ) { 
   Write-Warning "Exiting with code $LASTEXITCODE" 
   exit $LASTEXITCODE
}
### sample Powershell script continues here on `$LASTEXITCODE -eq 0` condition
Sign up to request clarification or add additional context in comments.

1 Comment

Thank-You so much @JosefZ . It is working as expected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.