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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return the file size using ccperl

Status
Not open for further replies.

gweber19

MIS
Nov 4, 2009
2
US
I am writing a trigger for ClearCase to prevent files e.g.)greater than 10 MB from being added to source control. We are using the ccperl that is installed with ClearCase. In my perl script, I've tried using the two examples below and it returns nothing:
1.
$filesize = -s "test.txt";
print "Size: $filesize\n;"

2.
use File::stat;
$filesize = stat("test.txt")->size;
print "Size: $filesize\n";

Any help is much appreciated. Thanks.

Gary
 
Have you tried using the built-in stat rather than modules? i.e.

Code:
[gray]#!d:\perl\bin\perl.exe -w[/gray]

[url=http://perldoc.perl.org/functions/use.html][black][b]use[/b][/black][/url] [green]strict[/green][red];[/red]

[url=http://perldoc.perl.org/functions/my.html][black][b]my[/b][/black][/url] [red]([/red][blue]$dev[/blue],[blue]$ino[/blue],[blue]$mode[/blue],[blue]$nlink[/blue],[blue]$uid[/blue],[blue]$gid[/blue],[blue]$rdev[/blue],[blue]$size[/blue],
     [blue]$atime[/blue],[blue]$mtime[/blue],[blue]$ctime[/blue],[blue]$blksize[/blue],[blue]$blocks[/blue][red])[/red]
             = [url=http://perldoc.perl.org/functions/stat.html][black][b]stat[/b][/black][/url][red]([/red][red]"[/red][purple]test.txt[/purple][red]"[/red][red])[/red][red];[/red]

[url=http://perldoc.perl.org/functions/print.html][black][b]print[/b][/black][/url] [red]"[/red][purple]size is [blue]$size[/blue][purple][b]\n[/b][/purple][/purple][red]"[/red][red];[/red]

Annihilannic.
 
Another one of my co-workers was able to look at this with me and he found that as soon as I was adding a new object to source control, ClearCase is changing the file from "new_object" to "new_object.mkelem" and that is why my script could not find the file or directory. Script is now working.
Thanks for your help and suggestions.
Gary
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top