Question about glob.glob <--newbie

David M. Cooke cookedm+news at physics.mcmaster.ca
Mon May 3 23:09:27 EDT 2004


At some point, "Sean Berry" <sean_berry at cox.net> wrote:

>>>> r = glob.glob('/*')
>>>> r
> ['/dev', '/usr', '/stand', '/etc', '/cdrom', '/proc', '/bin', '/boot',
> '/mnt', '/modules', '/root', '/sbin', '/tmp', '/var', '/sys', '/COPYRIGHT',
> '/kernel.GENERIC', '/kernel', '/compat', '/home', '/kernel.old',
> '/modules.old']
>>>>
>>>> r = glob.glob('/usr/websites/*')
>>>> r
> []
>
> I can do a
>>>> import os
>>>> dirs = os.system('ls /usr/websites')
>
> and that works.  Why doesn't glob.glob work on /usr/websites?

Somehow, I doubt that actually works. I'll bet that dirs == 0 -- os.system
returns the status code of the command, not the output. You'll want
commands.getoutput.

What are the permissions on /usr/websites? What does 'ls -l
/usr/websites' and 'ls -ld /usr/websites' give?

-- 
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca



More information about the Python-list mailing list