Using Perl to follow a symlink
Problem: If someone has a stupid app that puts a link say in /etc/rc3.d on say RedHat Linux chkconfig --list won't know about it because the corresponding source script isn't in /etc/init.d.
Solution:
In Perl after making use of the opendir call and reading all of the files you have two options to follow the symlink.
1. Blindly follow the symlink with open(FH,glob("Filename"))
2. Do it the more efficient way with readlink("filename"); This will return the path the link is pointing to
More info see perldoc perlfunc
0 Comments:
Post a Comment
<< Home