Perl: the Markov chain saw | |
PerlMonks |
Re: File Statistics from a shared directoryby Sinistral (Monsignor) |
on Aug 06, 2010 at 13:39 UTC ( [id://853407]=note: print w/replies, xml ) | Need Help?? |
For the first part of your program, you can use the Windows net use command. In Perl, you'll want to use the system() function to do your work:
Note that you could ask the user in your Perl script for the password so that you don't have to have the password hard coded in your Perl code. Then you would put your password variable (perhaps $password) in place of the hard coded string password. Because I'm using double quotes (which in Perl means to interpolate) I have had to double the backslashes to indicate that I want actual backslashes. If you change the quotes to single quotes and hard code the password you would only need 1 backslash for every two I show in the code. You also don't have to have a domain for the /USER flag. The Z: is the drive letter you want to map, and can be any unused letter on the computer I don't show it, but you'll want to check the return code to make sure your net use succeeded, or attempting to access the files won't work You can get file information on individual files by using the stat() function and passing the path to the file name (said path would include the newly mapped drive letter).
In Section
Seekers of Perl Wisdom
|
|