HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Perl: retrieve link info ??
Operating System - HP-UX
1834163
Members
2596
Online
110064
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2003 02:03 AM
04-11-2003 02:03 AM
Hi There,
Hope to be allowed to ask a perl question.
I can use stat() or lstat() to retrieve info about the file, but I have the following problem.
lstat($file) --> tells me all the info of the link
stat($file) --> tells me all the info the file it is linked to
But who do I find out what file it is linked to (in Perl)????
I do not want to find out using a syscal such as ; $f_info=`/usr/bin/ll $file`;
As this is eating resources. Anybody aware of a perl solution for getting the target fname ??
Regs David
Hope to be allowed to ask a perl question.
I can use stat() or lstat() to retrieve info about the file, but I have the following problem.
lstat($file) --> tells me all the info of the link
stat($file) --> tells me all the info the file it is linked to
But who do I find out what file it is linked to (in Perl)????
I do not want to find out using a syscal such as ; $f_info=`/usr/bin/ll $file`;
As this is eating resources. Anybody aware of a perl solution for getting the target fname ??
Regs David
@yourservice
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2003 02:45 AM
04-11-2003 02:45 AM
Solution
Hi David,
the perl function "readlink" will return a string indicating the target of the symbolic link. This may be a relative path from the link location or an absolute path depending upon how the link was set up.
"man perlfunc" gives you basic info on how to use it.
Hope this helps,
Stephen
the perl function "readlink" will return a string indicating the target of the symbolic link. This may be a relative path from the link location or an absolute path depending upon how the link was set up.
"man perlfunc" gives you basic info on how to use it.
Hope this helps,
Stephen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2003 02:51 AM
04-11-2003 02:51 AM
Re: Perl: retrieve link info ??
perl questions are always welcome.
readlink () gives you the first level of symbolic links. If the target is (again) a symlink, you'd better use the Cwd module:
use Cwd 'abs_path';
my $abs_path = abs_path($file);
# man Cwd
for the full description
Enjoy, have FUN! H.Merijn
readlink () gives you the first level of symbolic links. If the target is (again) a symlink, you'd better use the Cwd module:
use Cwd 'abs_path';
my $abs_path = abs_path($file);
# man Cwd
for the full description
Enjoy, have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2003 02:56 AM
04-11-2003 02:56 AM
Re: Perl: retrieve link info ??
Stephen,
Perfect !!! I just couldn't find it.
my $link_target = readlink($link_file);
print "File $link_file is linked to $link_target \n";
Great !!!
Regs David
Perfect !!! I just couldn't find it.
my $link_target = readlink($link_file);
print "File $link_file is linked to $link_target \n";
Great !!!
Regs David
@yourservice
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP