Perl file test help?
Feb. 25th, 2009 10:06 am![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
i'm avoiding madness and rage by cobbling together a Perl script. It needs to check a bunch of network files for various file characteristics (SQL server backup dumps, to be exact, by age: we have a gajillion of them and I am *not* checking them by hand). I'm having trouble getting my Perl script (I'm a Perl newbie but it had a badger on one of the books, and I'm taking my good omens where I can get them) to find files on the network. Any ideas?
There's a pint in it :)
my @file_list = ("print.gif", "..\\wWwroot\\sql_server_backups.pl", "c:\\datix.log", "\\\\cm017320\\c\$\\DATIX.log", "r:\\leaverlog.txt", "r:\\everyone_test.txt");
$output .= "\n<ol>";
foreach my $testfile (@file_list) {
if (-e $testfile){
$output .= "<li> $happystart $testfile exists. $happyend</li>";
}
else{
$output .= "<li> $grumpystart $testfile does not exist. $grumpyend</li>";
}
}
$output = $output . "</ol>\n";
Gives:
...all the files are known to be good. File 3 is the same as file 4, only with a UNC path. 6 has explicit "everyone = Full Control" file permissions. All machines are windows boxes, and the server is IIS running with the local system account on my box (which is cm017320). If I try to open a network file I get 'permission denied' so I'm guessing this is a permissions-looking-over-the-network kind of issue.
$output .= "\n<ol>";
foreach my $testfile (@file_list) {
if (-e $testfile){
$output .= "<li> $happystart $testfile exists. $happyend</li>";
}
else{
$output .= "<li> $grumpystart $testfile does not exist. $grumpyend</li>";
}
}
$output = $output . "</ol>\n";
Gives:
SQL Server Backups:
- print.gif exists.
- ..\wWwroot\sql_server_backups.pl exists.
- c:\datix.log exists.
- \\cm017320\c$\DATIX.log does not exist.
- r:\leaverlog.txt does not exist.
- r:\everyone_test.txt does not exist.
...all the files are known to be good. File 3 is the same as file 4, only with a UNC path. 6 has explicit "everyone = Full Control" file permissions. All machines are windows boxes, and the server is IIS running with the local system account on my box (which is cm017320). If I try to open a network file I get 'permission denied' so I'm guessing this is a permissions-looking-over-the-network kind of issue.
There's a pint in it :)
no subject
Date: 2009-02-25 11:53 am (UTC)Opening the files fails with access-denied, even for the Everyone:Full one and the one that's local. ActivePerl.
no subject
Date: 2009-02-25 11:57 am (UTC)But aside from that, let me try running that in a similar setup here and see whether I can reproduce your problem.
no subject
Date: 2009-02-25 12:20 pm (UTC)So, its not your perl thats weird.. its your file or directory permissions somehow.
no subject
Date: 2009-02-25 02:10 pm (UTC)(Isn't Python the thing that enables programmers to fly?)
no subject
Date: 2009-02-25 02:24 pm (UTC)(yes)
:)
no subject
Date: 2009-02-25 02:43 pm (UTC)Heh - my script works just fine if I run it from the command line. It's definitely a webserver-permissions issue. Cheers again.
no subject
Date: 2009-02-25 06:08 pm (UTC)no subject
Date: 2009-02-25 06:17 pm (UTC)no subject
Date: 2009-02-25 07:09 pm (UTC)HINT.