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
goe
  • 337
  • 2
  • 14

1 Answers1

1

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

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

should work

  • When i try this arg gets just added with prg, there should be a space because the executable expects argument with a space. – goe Oct 06 '20 at 13:59
  • 1
    os.system(prg + " " + arg) – user14394194 Oct 07 '20 at 11:56
  • 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. – goe Oct 07 '20 at 17:33
  • https://stackoverflow.com/questions/4760215/running-shell-command-and-capturing-the-output – user14394194 Oct 08 '20 at 05:04