Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Re: Partition names with Python (http://www.velocityreviews.com/forums/t319049-re-partition-names-with-python.html)

Andrew Bennetts 07-01-2003 08:25 AM

Re: Partition names with Python
 
On Tue, Jul 01, 2003 at 02:45:15AM +0000, Bengt Richter wrote:
>
> You might want to try something like
>
> import os
> print os.popen('mount').read()


Or simply reading /etc/mtab or perhaps /proc/mounts (this one is
linux-specific, I think), rather than spawning a process.

-Andrew.



Artur M. Piwko 07-01-2003 10:53 AM

Re: Partition names with Python
 
In the darkest hour on Tue, 1 Jul 2003 18:25:46 +1000,
Andrew Bennetts <andrew-pythonlist@puzzling.org> screamed:
>> You might want to try something like
>>
>> import os
>> print os.popen('mount').read()

>
> Or simply reading /etc/mtab or perhaps /proc/mounts (this one is
> linux-specific, I think), rather than spawning a process.
>


And /proc/partitions.

Artur

--
Before the Goat of Mendes... we all must take our turn | Artur M. Piwko
Into the magic circle... where still the fire burns | mailto:s/_/./
We're spinning round and round... until one takes a fall | -- Mercyful Fate
The fallen one will not return, the fallen one must burn | "Witches' Dance"

John Hunter 07-01-2003 03:13 PM

Re: Partition names with Python
 
>>>>> "Artur" == Artur M Piwko <pipen@beast_tu_kielce.pl> writes:

Artur> And /proc/partitions.

Best yet!

import os
fh = file('/proc/partitions')

fh.readline() # eat the header
fh.readline() # eat the blank line

partitions = [line.split()[-1] for line in fh.readlines()]
print partitions


Erhan Ekici 07-02-2003 08:17 AM

Re: Partition names with Python
 
Hi,

But some machines /proc/partition file is empty..
But /etc/fstab contain drives names..(sda1,sda2,cdrom,floopy etc)

For Example My Server(Slackware 9)'s /proc/partition file contain nothing.
I must take partition names on all Linux(Redhat,Mandrake,Slackware etc)..

Why do some machine's /proc/partition file contain nothing...

Erhan,

Quoting John Hunter <jdhunter@ace.bsd.uchicago.edu>:

> >>>>> "Artur" == Artur M Piwko <pipen@beast_tu_kielce.pl> writes:

>
> Artur> And /proc/partitions.
>
> Best yet!
>
> import os
> fh = file('/proc/partitions')
>
> fh.readline() # eat the header
> fh.readline() # eat the blank line
>
> partitions = [line.split()[-1] for line in fh.readlines()]
> print partitions
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



--

Erhan Ekici
ITU Center for Distance Learning
E-Mail : erhan@uzem.itu.edu.tr





Artur M. Piwko 07-02-2003 01:53 PM

Re: Partition names with Python
 
In the darkest hour on Wed, 2 Jul 2003 11:17:49 +0300,
Erhan Ekici <erhan@uzem.itu.edu.tr> screamed:
> But some machines /proc/partition file is empty..
> But /etc/fstab contain drives names..(sda1,sda2,cdrom,floopy etc)
>
> For Example My Server(Slackware 9)'s /proc/partition file contain nothing.
> I must take partition names on all Linux(Redhat,Mandrake,Slackware etc)..
>
> Why do some machine's /proc/partition file contain nothing...
>


Yes, you have to compile it to kernel.

The best choice is /etc/mtab, imho.


Artur

--
Before the Goat of Mendes... we all must take our turn | Artur M. Piwko
Into the magic circle... where still the fire burns | mailto:s/_/./
We're spinning round and round... until one takes a fall | -- Mercyful Fate
The fallen one will not return, the fallen one must burn | "Witches' Dance"


All times are GMT. The time now is 09:37 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57