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

I have written a script that is able to authenticate into a server and from there searches a directory and parses files in the directory. The current method I'm using to authenticate into the servers is:
qx|net use \\\\$server\\C\$\\VoiceGenie\\mp\\log $ServerPassword /use +r:$username|; find( \&finddata, "\\\\$server\\c\$\\VoiceGenie\\mp\\logs\ +\" ) or warn "Could not enter the specified path \\\\$server\\ +c\$\\VoiceGenie\\mp\\logs\\.\n"; #Function that allows the use of Fil +e::Find. qx|net use \\\\$server\\C\$\\VoiceGenie\\mp\\log /D|;
However, I feel that this may not be the best method by which to do so. For one when doing this I always recieve System error 55. This error has meant nothing to me, but the fact that it occurs is some what troubling. Also sometimes if the script is run multiple times in a row it will fail to connect to the server. Giving me an error that states "Could not enter the specified path ...path name here...The network connection could not be found. I am wondering if there is a better way by which I can connect to these servers. They are windows servers, and it is not possible for me to map all the servers to my machine because this code will be used by many people and is set to search close to 20 servers. Thank you for any help in advance.

Replies are listed 'Best First'.
Re: Server authentication
by ww (Archbishop) on Apr 09, 2012 at 21:18 UTC
    I don't see anything in your code that explains either problem (but then, you haven't told us enough (module? for instance) about your code to be sure).

    However, a search for information on the error (using duckduckgo in this case) produces a wealth of information. I commend it to you, in the belief that anytime running a script kicks up an error message, one is well-advised to -- at least -- find out what the error message means.

    A short-form precis of one common datum found in the many hits references above: one or more of the sites you're trying to reach has some (pretty serious) problems.

Re: Server authentication
by Marshall (Canon) on Apr 10, 2012 at 03:41 UTC
    Some comments:

    More code is needed in order to have an accurate and reproducible solution to this problem.

    -First: use / instead of \\.
    This reduces the number of "leaning toothpicks", "\\\\".
    In Perl, "/" always works instead of "\\".
    In Windows XP+, "/" or "// "almost always works".
    There are some expections to this (where the backslash
    \ or \\ is needed).

    -Second: qx is rare: qx.
    Perhaps "system" or other method is better?
    I just note that qx is rare.
    my $return = `some comand`;
    would be more common.

    -Third: File::Find
    There is no returned value from File::Find. If you meant that by the subroutine find().

    Update:
    Here is the case where you need the "\" on the Windows command line:

    C:\Projects>cd c:/temp The system cannot find the path specified. C:\Projects>cd c:\temp C:\TEMP>
    A directory path in Perl doesn't use the Windows command line. This weird situation only happens if you are running a Windows shell command and starting from the "drive"'s root.

    this is ok.... C:\TEMP>cd ../temp/somedir C:\TEMP\somedir>
      What other information about the file can I provide in order to aid in finding a solution? I was hesitant to post much more because the entire code is 1000 lines long.
        Well,
        ERROR_DEV_NOT_EXIST
        55 (0x37)
        The specified network resource or device is no longer available.

        Can you replicate the error without 1,000 lines code?