Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

utime permissions

Status
Not open for further replies.

ironpawz

IS-IT--Management
Oct 8, 2002
44
0
0
NZ

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(&quot;,&quot;, $title[$i]); # split the line into its 2 arrays
$new[$i] = &quot;$file1[$i] $size[$i]&quot;; # 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 &quot;File name # $filez\n&quot;;
print &quot;Previous date # $access\n&quot;;
utime $access, $access, $filez || die print &quot;couldn not set utime for $filez\n&quot;;
}
}

 
Interesting seems there is no way for perl to set the last changed date on a file you do not own from Windows.
I posted this question in a few places and no ideas.

Anyone know of a dos tool to set file access using long filenames? I have found loads that only work with short names.

If I try
$filez=x:\fileiown.doc; # a file i own on network share
$access=time;
utime $access, $access, $filez #this will work fine

$filez=x:\file_u_own.doc; # a file i dont own on network share (but have write access to)
$access=time;
utime $access, $access, $filez #this will not work

Can it be that perl has no win32 answer to such a simple thing?


################
All life is Kaos
################
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top