I’m using Python and Envoy. I need to delete all files in a directory. Apart from some files, the directory is empty. In a terminal this would be:
rm /tmp/my_silly_directory/*
Common sense dictates that in envoy, this translates into:
r = envoy.run('rm /tmp/my_silly_directory/*')
However:
r.std_err -> "rm: cannot remove `/tmp/my_silly_directory/*': No such file or directory"
Naturally there are alternatives to using envoy in this case, I am simply wondering why it doesn’t work.
Any clues?
On UNIX, it’s up to the shell to interpret wildcards like
*. If you execute a program and pass an argument with*in it directly to the program — which is presumably what’s being done here — then you’ll get an error like you’re seeing.rmjust assumes the*is a file name, and indeed, it’s actually possible to create such a file.One solution could be to execute the shell and let it execute your command on your behalf, something like
The shell will interpret the
*before invokingrm.