Help with Python

Christos TZOTZIOY Georgiou tzot at
Wed Sep 17 00:48:03 CEST 2003

On Tue, 16 Sep 2003 14:16:56 -0700, rumours say that "Fernando Armenta"
<farmenta at> might have written:

>I need to check for a directory and move it to other directory if is
>found.  The directory always starts with outlog.XYZ and ends in XYZ
>(where XYZ are variables).  I need to use wild characters.  Here is what
>I have, but is not working.  Any help would be appreciated.  
>#Path for the file
>home_trace = "/home/testeng/ca/tds/outlog.* "
>#Path for the directory where I want to move the file
>directory = "/home/testeng/ca/tds/unattached"
>#If statement 
>if os.path.exists(home_trace):
>        os.system ("chmod -fR 775 outlog.* ")
>        os.system ("mv outlog.* " + directory)

Import glob, then for each file in glob.glob('outlog.*'), use os.chmod()
and os.rename() with appropriate parameters.  os.rename() would probably
fail if you moved your files to another filesystem, but in your example
this does not seem to be the case.

PS I just remembered that I have seen at least one C++ freshly-graduated
programmer serving as a sysadm in a university praising C++ as a
scripting language (!); his code was full of system() calls.  When I
asked him, "why not a shell script?", he said "this is faster... it's
I mentioned the difference of a shell doing spawn() and an executable
doing spawn() to a shell doing another spawn().
Discussing it further, he said that executables are not "legible"; so,
*just before* suggesting a "chmod 500" operation on a root-owned script,
I told him about the "strings" command as an obvious counter-argument
for a naive disassembly.  I chose the wrong order of sentences; he
actually removed /usr/bin/strings in haste, as if his job was depending
on its disappearance...  FWIW, it did --in the opposite way.
There are no limits.
TZOTZIOY, I speak England very best,
Microsoft Security Alert: the Matrix began as open source.

More information about the Python-list mailing list