Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Connecting to network shared drive

by ikegami (Pope)
on May 27, 2008 at 20:14 UTC ( #688779=note: print w/replies, xml ) Need Help??


in reply to Connecting to network shared drive

Windows has invisible shares called C$, D$, etc representing C:, D:, etc.

If the machine you wish to poll has file sharing enabled,
if the machine on which the program runs is a Win32 machine with "Client for Microsoft Networks" enabled, and
if your login and password is the same for that machine as it is for the current machine,
then you can just open \\machine\c$\some\dir (or //machine/c$/some/dir if it's easier) using opendir. Win32::ChangeNotify will also accepts such a path.

use strict; use warnings; my $path = '\\\\godzilla\\c$\\temp'; for (;;) { my $count = () = do { opendir my $dh, $path or die; readdir($dh) }; print("$count\n"); sleep(2); }
2 2 2 2 3 3 3 4 Terminating on signal SIGINT(2)
use strict; use warnings; use Win32::ChangeNotify qw( FILE_NOTIFY_CHANGE_DIR_NAME FILE_NOTIFY_CHANGE_FILE_NAME ); my $path = '\\\\godzilla\\c$\\temp'; for (;;) { my $count = () = do { opendir my $dh, $path or die; readdir($dh) }; print("$count\n"); my $notify = Win32::ChangeNotify->new($path, 0, FILE_NOTIFY_CHANGE_ +DIR_NAME|FILE_NOTIFY_CHANGE_FILE_NAME); $notify->wait or die; }
2 3 4 Terminating on signal SIGINT(2)

Update: Added code.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://688779]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2021-10-19 12:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (76 votes). Check out past polls.

    Notices?