Linux info

T

TheSaint

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
 
V

vasudevram

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.realpath 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
http://www.geocities.com/vasudevram
PDF conversion tools: http://sourceforge.net/projects/xtopdf
 
J

Jorgen Grahn

Hello there,

I still learning, but I couldn't find anything which tells me where a
symlink is pointing to.

os.readlink()
os.lstat()

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

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

/Jorgen
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top