Yes the problem is the separator you've used for the filepath, a \ is in c language means escape the next character, example \n means a new line.
So you MUST double up the backslashes or use forward slashes (yes it will work on windows).
You've got the number of minutes since the 1st January 1970.
Here is my example that works:
print("Age of file is ".((timeNow-fileTime)/60)."\n");
1 of 1 people found this helpful
Johan Landerholm wrote:
I thought the file() command should return the number of seconds since the file was created ?...
For creation time of a file, you need use flag [enhanced] of a PSL-function file, and then extract the 3-rd argument from results (for details see "PATROL Script Language Reference Manual Volume 2—PSL Functions" ).
file( filename, [enhanced] )
For your case, with additions of Jon, the resulting code might be:
fpath = "c:\\tmp\\CTX.DAT";
tid = time();
fctime = ntharg( file( fpath, 1 ), 3, " " );
if ( "" == fctime )
printf("[ERROR] Can't find '%s'\n", fpath );
fage_sec = tid - fctime;
fage_min = fage_sec / 60;
printf( "[INFO] File Age: %d mins (ctime: %s)\n", fage_min, asctime( fctime ) );
Hope it helps...