I’m trying to create a series of tar files from within Python code. As a practice I have a subdirectory – ‘O’, which contains the files I want to tar. When I try typing
tar -cf O.tar ./O
from the command line, things work. But, when I enter the Python interpreter and enter
import subprocess
subprocess.call(["tar","-cf O.tar ./O"])
I get the following error:
tar: Cowardly refusing to create an empty archive
Does this make sense? I tried
import os
os.listdir(".")
To make sure I could still see my “O” subdirectory from within the Python shell, and I can.
What am I missing here?
maybe.