Home > Net >  passing variable value in subprocess.run python
passing variable value in subprocess.run python

Time:11-26

How do I call this variable sd_namesp in subprocess run ? when I try to do this using below method, I get invalid syntax I also tried f"{sd_namesp}" that doesn't works either

for seccontent in sec_ver_data:
    sd_namesp = seccontent.get("name")   seccontent.get("ition")   str(seccontent.get("version")
    largs = ['java','-jar','cli.jar','n','-cf', config_path, '-r', seccontent.get("reg"), '-n', seccontent.get("name"), '-i', seccontent.get("sid"), '-f', sd_namesp]
    lresp = subprocess.run(largs, text=True, capture_output=True, check=True)
    print(lresp.stdout)
print("end")

CodePudding user response:

You're probably getting a syntax error because it looks like you forgot to close your parenthesis here:

sd_namesp = seccontent.get("name") seccontent.get("ition") str(seccontent.get("version"))

Notice the extra parentheses at the end.

  • Related