On Fri, May 2, 2008 at 12:08 PM, Spencer Parker <[EMAIL PROTECTED]> wrote:
> I need to use a regular expression to get a couple of items for my python
> script.  So far the script is running an 'ls' command to get a few items
> that I need
>
> I run an 'ls -sk /xen/domains2/machinename/disk.img'
>
> Output
>
> 2454112 /xen/domains2/machinename/disk.img

Look at os.path.getsize(). You don't need to use ls to get this information.

> What I need to get is just the size numbers using regular expressions.

You could just use str.split() but getsize() is better.

> I also need to get the 'machinename'
> portion of the path as well to stick into the database.

Don't you already know this? Where does the ls command come from?
Anyway look at os.path.split() and os.path.dirname().

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to