HamNRye has asked for the wisdom of the Perl Monks concerning the following question:
Greets Monks...
I am trying to monitor a directory. I am running on Windows2000 with activestate 5.6. My standard "get_dir" routine is used for both these files. (wlog just puts a timestamp on the line and writes it to a log.)
sub get_dir { my $dir = shift ; opendir(DIR, $dir) || wlog( "Cannot open dir: $dir." ); my @files = grep !/^\.\.?$/, readdir DIR ; closedir DIR; return @files ; }
The problem is that the machine I want this to run on constantly complains about not being able to read the directory... I can get the directory listing from my workstation. I have been running a script that writes out the file count and then having the other program read the file. Not optimal. Here are both code snips:
#! /usr/bin/perl # This one works sub main { @total1 = get_dir("\\\\RICH0417\\d\$\\wirein"); @total2 = get_dir("\\\\RICH0418\\d\$\\wirein"); @total = (@total1, @total2); open (F, ">E:\\wirecount.txt")|| die("Cannot open file."); print F ($#total + 1); close F; print STDOUT "."; sleep 30; main(); }
sub do_wire { #Non-working.... my @wire1 = get_dir("\\\\RICH0417\\d\$\\wirein") || wlog("Cannot get w +ire1."); my @wire2 = get_dir("\\\\RICH0418\\d\$\\wirein") || wlog("Cannot get w +ire2."); my @wiretotal = (@wire1, @wire2); my $wire = ($#wiretotal + 1); my $wire = get_file("C:\\wirecount.txt"); if ($wire < 100) { $wirestat = "green"; } else { $wirestat = "red"; } return $wire; }
Anybody have some things I can look into as far as getting this?? I have even tried:
to mount the drive. Note that I can mount the drive from the desktop via the usual windows methods.system("net use /USER:USERNAME Q: \\\\RICH0417\\d$\\Temp PASSWORD") == + 0 && wlog("Q:\ Mounted");
Finally, from the log:
14:28 1-17-2003 >> Cannot open dir: \\RICH0417\d$\wirein. 14:28 1-17-2003 >> Cannot get wire1. 14:28 1-17-2003 >> Cannot open dir: \\RICH0418\d$\wirein. 14:28 1-17-2003 >> Cannot get wire2.
Thanks for your help...
~Hammy
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: open dir on Win32
by Fletch (Bishop) on Jan 17, 2003 at 19:42 UTC | |
by HamNRye (Monk) on Jan 17, 2003 at 20:57 UTC | |
|
Re: open dir on Win32
by Marza (Vicar) on Jan 17, 2003 at 20:06 UTC | |
by HamNRye (Monk) on Jan 17, 2003 at 21:04 UTC | |
by Marza (Vicar) on Jan 17, 2003 at 22:02 UTC | |
by HamNRye (Monk) on Jan 17, 2003 at 22:11 UTC |