0

I am working on running an executable through python to connect to a cyberarc vault. When i run executable in command line it works, but in python i am not able to get the result.

I have tried both os.system and subprocess but no help.

Please help

import os
import subprocess
prg = "D:\File\CyberArk\ApplicationPasswordSdk\CLIPasswordSDK.exe"

arg = "GetPassword /p AppDescs.AppID=XXXXX-X-1 /p Query=XXXXXXXXXXXXXXXXX;Object=XXXXXXXX-USERID /o Password"

passw = os.system('prg arg') # I have this and as well below with subprocess

passw = subprocess.Popen([r'prg', 'arg'])

print(passw)

In command line below will work -

"D:\File\CyberArk\ApplicationPasswordSdk\CLIPasswordSDK.exe" GetPassword /p AppDescs.AppID=XXXXX-X-1 /p Query=XXXXXXXXXXXXXXXXX;Object=XXXXXXXX-USERID /o Password
2
  • You're printing pass, but store the result in passw. Typo only in the question, or is the typo also in the code you run? Commented Oct 6, 2020 at 13:31
  • @ErikBotö - Apologies, it was typo in question :) Commented Oct 6, 2020 at 13:32

1 Answer 1

1

It tries to execute prg arg in the CMD, simpy remove the '

passw = os.system(prg + " " + arg)

should work

Sign up to request clarification or add additional context in comments.

4 Comments

When i try this arg gets just added with prg, there should be a space because the executable expects argument with a space.
os.system(prg + " " + arg)
Thank you heaps. I had used this. I am running out in a problem The password is displaying in console... I tried to save in variable but its always printing in console, the argument /o Password is printing it. Is there a way to save the console output to a variable.

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.