I am using the subprocess module to create some directories. However in some cases the same command might be creating directories in restricted directories. In such cases I get an output to the console: mkdir: cannot create directory 'location/to/directory': Permission denied
How to avoid this output to the console?
I have tried the following commands:
subprocess.run(["mkdir", "-p", f"{outdir}/archive/backup_{curr_date}/"],check=True,stdout=subprocess.DEVNULL)
subprocess.run(["mkdir", "-p", f"{outdir}/archive/backup_{curr_date}/"],check=True,stdout=subprocess.PIPE)
subprocess.run(["mkdir", "-p", f"{outdir}/archive/backup_{curr_date}/"],check=True,capture_output=True)