-1

I have a command as below

Result = os.open(“curl -u username:password https://hostname/stafftools/reports/all_users.csv -k”).read()

It’s returning nothing.

can someone help me out?

Chandella07
  • 2,089
  • 14
  • 22
  • `os.system(“curl -u username:password https://hostname/stafftools/reports/all_users.csv -k”)` – Raoslaw Szamszur Nov 20 '18 at 16:07
  • 1
    Possible duplicate of [Calling an external command in Python](https://stackoverflow.com/questions/89228/calling-an-external-command-in-python) – s3cur3 Nov 20 '18 at 16:07
  • https://unix.stackexchange.com/questions/238180/execute-shell-commands-in-python – Raoslaw Szamszur Nov 20 '18 at 16:08
  • This is working fine....problem with curl not available in pycharm.....installed curl in pycharm....then after all commands.....os.open....os.system....subprocess giving same results. Thank you!! – Krishna Nagidi Nov 23 '18 at 04:44

1 Answers1

1

You should use the subprocess module:

import subprocess

result = subprocess.call(["curl", "-u", "username:password", "https://hostname/stafftools/reports/all_users.csv", "-k"]) 

Find more information here.

berkelem
  • 2,005
  • 3
  • 18
  • 36