Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have written a perl script that needs to be able to access information located on various servers. However, all of these servers are password protected. Thus I am looking for a way to pass the necessary login information, so that I can access the data in the server. The piece of code I am using to access the server is given below.
foreach $server ( @servers ) { if( $found == 0 ) { find( \&finddata, "\\\\$server\\c\$\\VoiceGenie\\mp\\logs\\" ) + or warn "Could not enter the specified path \\\\$server\\c\$\\VoiceG +enie\\mp\\logs\\.\n"; } }

Replies are listed 'Best First'.
Re: server login
by NetWallah (Canon) on Feb 24, 2012 at 23:28 UTC
    It looks like you are accessing Windows servers via CIFS.

    If so, you can try to shell-execute a command like:

    net use \\<servername>\C$\VoiceGenie\mp\log <ServerPassword> /user:<U +serName>
    before your access attempt. After you are done, do :
    net use \\<servername>\C$\VoiceGenie\mp\log /D
    To "forget" the virtual mount.

                “PHP is a minor evil perpetrated and created by incompetent amateurs, whereas Perl is a great and insidious evil perpetrated by skilled but perverted professionals.”
            ― Jon Ribbens

      First, thank you for your response to my question. I have tried to implement this but it is giving me some trouble with the syntax, not too worried just need to mess around with it more. I am wondering though, how would I implement this in my actual perl code? I need to be able to perform this log in log many times for different servers. Thank you in advance.
        Try something like :
        qx|net use \\\\<servername>\\C\$\\VoiceGenie\\mp\\log $ServerPasswo +rd /user:$username|;

                    “PHP is a minor evil perpetrated and created by incompetent amateurs, whereas Perl is a great and insidious evil perpetrated by skilled but perverted professionals.”
                ― Jon Ribbens

Re: server login
by JavaFan (Canon) on Feb 24, 2012 at 22:13 UTC
    LWP or WWW::Mechanize isn't working for you?