Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Partition names with Python

Reply
Thread Tools

Re: Partition names with Python

 
 
Andrew Bennetts
Guest
Posts: n/a
 
      07-01-2003
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.


 
Reply With Quote
 
 
 
 
Artur M. Piwko
Guest
Posts: n/a
 
      07-01-2003
In the darkest hour on Tue, 1 Jul 2003 18:25:46 +1000,
Andrew Bennetts <(E-Mail Removed)> 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"
 
Reply With Quote
 
 
 
 
John Hunter
Guest
Posts: n/a
 
      07-01-2003
>>>>> "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

 
Reply With Quote
 
Erhan Ekici
Guest
Posts: n/a
 
      07-02-2003
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 <(E-Mail Removed)>:

> >>>>> "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 : http://www.velocityreviews.com/forums/(E-Mail Removed)




 
Reply With Quote
 
Artur M. Piwko
Guest
Posts: n/a
 
      07-02-2003
In the darkest hour on Wed, 2 Jul 2003 11:17:49 +0300,
Erhan Ekici <(E-Mail Removed)> 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"
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dd - unequal speed from partition to partition, partition to file,file to partition bolega C Programming 1 03-28-2011 07:37 PM
Dual-boot - how to boot old XP-partition in FAT on NTFS partition next to Win XP ? Dutch Treat Computer Support 0 12-06-2004 11:13 AM
Trying to resize partition using Partition Magic 8.0 Mike Computer Support 4 01-29-2004 06:54 PM
Help..Partition magic made my partition disappear into oblivion Pierre Jarry Computer Support 6 07-14-2003 04:54 AM
Partition names with Python Erhan Ekici Python 0 06-30-2003 02:44 PM



Advertisments