I'm doing a project at work were I need to get the version of Java for 100's of servers. I been using readlink, but that gives me full path for the link. I'm trying to figured out a way to only get the last directory using Python.
>>> f = os.system('readlink /dir/dir/dir/java')
/dir/dir/dir/dir/jdk
I need the output to only be JDK
.
After some further research I figured it out. Once I got the output from
os.readlink
I then took the output and got the basename: