how to get the stat information for war file using perl
I have Perl script that gets stat information for a given file. But it does not work for .war
file. (This file has symbolic link.)
I am passing file location which has multiple files.
$fntxt
points to /dw/xyz/file1.txt
. file1.txt
has /vob/vob1/test.war
.
Executing @Stats=stat($ln);
returns an empty array for a .war
file.
open(DAT, $fntxt);
@fnames=<DAT>;
close(DAT);
print "@fnames\n";
foreach $ln (@fnames)
{
chomp $ln;
$i = length $ln;
if ($i>0)
{
@Stats=stat($ln);
if (!@Stats)
{
print "File [$ln] specified in [$fntxt] does not exist. Correct then rerun.\n";
exit 255;
}
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)
= localtime((stat($ln))[9]);
$mon += 1;
$year += 1900;
$tstamp = sprintf("%04d%02d%02d%02d%02d.%02d",
开发者_如何学Python$year,$mon,$mday,$hour,$min,$sec)
}
Any help would be appreciated.
With a symbolic link (assuming some flavor of unix) you want the permissions on the file being linked to, not the link. Use -l to detect that the file is a symbolic link and readlink to find out what it is linked to. If there are multiple links (i.e. link to link ...) follow them until you find the file.
精彩评论