I have a script that reads a groups of files and records the filename and last changed date. I have another that reads that file and returns files to their last used dates. this works fine on files I own sitting on our samba shares.
However files I do not own but I can still write and change are not getting set. I read a little about utime (my script is run from a windows system accessing the shares via samba). It looks like it may never work for this type of thing. Is there another less fussy way to do this or something else I am missing? The script I am using follows.
Note it is a rip of one of my earlier ones so the variable names make little sense.
It looks like it runs fine but only the dates on files I own change. Would it work run as root from the unix box? alternatives?
Thanks
use Win32::OLE;
use File::stat;
open(CSV, "c:/temp/doctime.txt"
@title = <CSV>;
for ($i = 0; $i < scalar(@title); $i++) # a for loop has three fields. the first sets a counter ($i=0)
{
($file1[$i], $size[$i], $csv1[$i], $person[$i]) = split(",", $title[$i]); # split the line into its 2 arrays
$new[$i] = "$file1[$i] $size[$i]"; # create a new array with csv first
}
@sortline = sort {$a cmp $b} @new; # I don't now the details of why but this sorts the line in order
@sortcsv = sort {$a cmp $b} @csv1; # so we have a list of just CSV's in order and a list of the whole line
for ($a = 0; $a < scalar(@file1); $a++)
{
if (0 == 0)
{
$access=$size[$a];
$filez = $file1[$a];
print "File name # $filez\n";
print "Previous date # $access\n";
utime $access, $access, $filez || die print "couldn not set utime for $filez\n";
}
}