Re: Partition names with Python

Discussion in 'Python' started by Andrew Bennetts, Jul 1, 2003.

  1. 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.
    Andrew Bennetts, Jul 1, 2003
    #1
    1. Advertising

  2. In the darkest hour on Tue, 1 Jul 2003 18:25:46 +1000,
    Andrew Bennetts <> 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"
    Artur M. Piwko, Jul 1, 2003
    #2
    1. Advertising

  3. Andrew Bennetts

    John Hunter Guest

    >>>>> "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
    John Hunter, Jul 1, 2003
    #3
  4. Andrew Bennetts

    Erhan Ekici Guest

    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 <>:

    > >>>>> "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 Ekici, Jul 2, 2003
    #4
  5. In the darkest hour on Wed, 2 Jul 2003 11:17:49 +0300,
    Erhan Ekici <> 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"
    Artur M. Piwko, Jul 2, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Erhan Ekici

    Partition names with Python

    Erhan Ekici, Jun 30, 2003, in forum: Python
    Replies:
    0
    Views:
    861
    Erhan Ekici
    Jun 30, 2003
  2. Xah Lee
    Replies:
    41
    Views:
    1,054
    Paul McGuire
    Feb 24, 2005
  3. Xah Lee
    Replies:
    10
    Views:
    563
    Erik Max Francis
    Feb 27, 2005
  4. Hellmut Weber
    Replies:
    8
    Views:
    1,287
    Seebs
    Oct 5, 2010
  5. bolega
    Replies:
    1
    Views:
    681
    Stan Bischof
    Mar 28, 2011
Loading...

Share This Page