andygates: (Default)
[personal profile] andygates
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?

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:

SQL Server Backups:

  1. print.gif exists.
  2. ..\wWwroot\sql_server_backups.pl exists.
  3. c:\datix.log exists.
  4. \\cm017320\c$\DATIX.log does not exist.
  5. r:\leaverlog.txt does not exist.
  6. 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  :)

Date: 2009-02-25 11:51 am (UTC)
calum: (Default)
From: [personal profile] calum
Are you using Cygwin Perl, or Perl for Windows (Active Perl)? It shouldnt matter, but it might.

Why are you using -e? You care if the file exists, but not if you have access to it? You tried using -r (for readable)?

I'm wondering if there is some sort of quirk about access to the directories the files are contained in.. Perl probably read the directory rather than the file to check if it exists.

The other thing you can try, is to actually open the file - and see if that fails.

Profile

andygates: (Default)
andygates

April 2017

S M T W T F S
      1
2345678
9 101112131415
16171819202122
23242526272829
30      

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 9th, 2025 12:02 pm
Powered by Dreamwidth Studios