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:

system("net use /USER:USERNAME Q: \\\\RICH0417\\d$\\Temp PASSWORD") == + 0 && wlog("Q:\ Mounted");
to mount the drive. Note that I can mount the drive from the desktop via the usual windows methods.

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


In reply to open dir on Win32 by HamNRye

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.