Hello,
I'm new to this board and perl. I did some searching but coul dnot resolv emu issue.
I'm trying to get a file UID and GIU, and then set it if needed. I used stat, but in my code its returing nothing, litterly nothing. For . and .. it seems to work, but my testfile.txt nothing is returned. If I ls -al testfile.txt I see my user and group assigned to the file.
Why is...
$FileUser = (stat($file))[4];
$FileGroup = (stat($file))[5];
@FileArray = stat($file);
...returning nothing ? I'm running Komodo debug on SUSE 10.3.
TIA
Code:
for ($i=0; $i<@DcbDir; $i++)
{
$CurrentDir = $DcbDir[$i];
opendir(DIR, $CurrentDir) || die ("FAILURE: Cannot open $CurrentDir !\n");
@dirlist = readdir(DIR);
closedir(DIR);
print "CURRENT DIR: $CurrentDir \n\n";
foreach $file (@dirlist)
{
$FileUser = (stat($file))[4];
$FileGroup = (stat($file))[5];
@FileArray = stat($file);
if(($file eq '.') || ($file eq '..'))
{
next;
}
if(($FileGroup ne '100') || ($FileUser ne '1000'))
{
print "$CurrentDir$file is not in dcb group, $FileGroup, $FileUser, $file ! \n";
if (($file eq '.reports') && (-d $file))
{
#exec "chown -Rf sroot:dcb $CurrentDir$file";
chown(0, 503, $file);
}
else
{
#exec "chown -f sroot:dcb $CurrentDir$file";
chown(0, 503, $file);
}
}
#print "File group is: $FileGroup, File user is: $FileUser, $file \n";
}
}
I'm new to this board and perl. I did some searching but coul dnot resolv emu issue.
I'm trying to get a file UID and GIU, and then set it if needed. I used stat, but in my code its returing nothing, litterly nothing. For . and .. it seems to work, but my testfile.txt nothing is returned. If I ls -al testfile.txt I see my user and group assigned to the file.
Why is...
$FileUser = (stat($file))[4];
$FileGroup = (stat($file))[5];
@FileArray = stat($file);
...returning nothing ? I'm running Komodo debug on SUSE 10.3.
TIA
Code:
for ($i=0; $i<@DcbDir; $i++)
{
$CurrentDir = $DcbDir[$i];
opendir(DIR, $CurrentDir) || die ("FAILURE: Cannot open $CurrentDir !\n");
@dirlist = readdir(DIR);
closedir(DIR);
print "CURRENT DIR: $CurrentDir \n\n";
foreach $file (@dirlist)
{
$FileUser = (stat($file))[4];
$FileGroup = (stat($file))[5];
@FileArray = stat($file);
if(($file eq '.') || ($file eq '..'))
{
next;
}
if(($FileGroup ne '100') || ($FileUser ne '1000'))
{
print "$CurrentDir$file is not in dcb group, $FileGroup, $FileUser, $file ! \n";
if (($file eq '.reports') && (-d $file))
{
#exec "chown -Rf sroot:dcb $CurrentDir$file";
chown(0, 503, $file);
}
else
{
#exec "chown -f sroot:dcb $CurrentDir$file";
chown(0, 503, $file);
}
}
#print "File group is: $FileGroup, File user is: $FileUser, $file \n";
}
}