Linux info

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TheSaint

    #1

    Linux info

    Hello there,

    I still learning, but I couldn't find anything which tells me where a
    symlink is pointing to.
    A part of os.system('ls -l ' + path) and cutting down to the need, I haven't
    got any specialized function.

    F
  • faulkner

    #2
    Re: Linux info

    os.path.realpat h

    TheSaint wrote:[color=blue]
    > Hello there,
    >
    > I still learning, but I couldn't find anything which tells me where a
    > symlink is pointing to.
    > A part of os.system('ls -l ' + path) and cutting down to the need, I haven't
    > got any specialized function.
    >
    > F[/color]

    Comment

    • vasudevram

      #3
      Re: Linux info

      os.system('ls -lL ' + path)
      should also work. But check, I may be wrong about the L option, and am
      not near a Linux system right now.

      That's "lL" - a small letter l (ell) followed by a capital letter L in
      the ls options above.

      This way may be slower than os.path.realpat h if that is implemented as
      a system call, i.e.via Python ->C->Linux kernel, which it probably is.
      Slower since my way given above will create a new process to run the ls
      command in. Just mentioning it as another way, plus, it does have the
      small benefit that it'll work the same way on any other language such
      as Perl, Ruby, etc., which supports something similar to os.system().

      Vasudev Ram
      Latest news coverage, email, free stock quotes, live scores and video are just the beginning. Discover more every day at Yahoo!

      PDF conversion tools: http://sourceforge.net/projects/xtopdf


      faulkner wrote:[color=blue]
      > os.path.realpat h
      >
      > TheSaint wrote:[color=green]
      > > Hello there,
      > >
      > > I still learning, but I couldn't find anything which tells me where a
      > > symlink is pointing to.
      > > A part of os.system('ls -l ' + path) and cutting down to the need, I haven't
      > > got any specialized function.
      > >
      > > F[/color][/color]

      Comment

      • Jorgen Grahn

        #4
        Re: Linux info

        On Tue, 13 Jun 2006 22:06:42 +0800, TheSaint <fc14301589@icq mail.com> wrote:[color=blue]
        > Hello there,
        >
        > I still learning, but I couldn't find anything which tells me where a
        > symlink is pointing to.[/color]

        os.readlink()
        os.lstat()

        And they are /not/ Linux-specific; expect them to work on most or all
        Unix-like OSes.
        [color=blue]
        > A part of os.system('ls -l ' + path) and cutting down to the need, I haven't
        > got any specialized function.[/color]

        Both functions mentioned above are documented as part of module os, section
        "Files and Directories".

        /Jorgen

        --
        // Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu
        \X/ snipabacken.dyn dns.org> R'lyeh wgah'nagl fhtagn!

        Comment

        Working...