File::Find package

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pankajit09
    Contributor
    • Dec 2006
    • 296

    File::Find package

    File::Find traverses a network folder also.

    If I give \\ipaddress\dir it works but not when \\ipaddress .

    How to make it traverse all the shared folders of a machine by inputting the IPAddress only?
  • ezechiel
    New Member
    • Jul 2009
    • 53

    #2
    I don't know, but isn't it possible to put the directories of \\ipaddress in a list and then do a find in that list?

    But I don't know if this works (just starting with Perl):
    Code:
    my $homedir = "\\\\ipaddress";
    opendir (IMD, $homedir) or die "Couldn't find dir: IMD ($!)";
    my @thefiles= readdir(IMD);
    closedir(IMD);

    Comment

    • RonB
      Recognized Expert Contributor
      • Jun 2009
      • 589

      #3
      Originally posted by pankajit09
      File::Find traverses a network folder also.

      If I give \\ipaddress\dir it works but not when \\ipaddress .

      How to make it traverse all the shared folders of a machine by inputting the IPAddress only?
      You can't

      A unc path is \\server(name or ip)\sharename\dir where dir is optional

      Without the sharename the unc path is incomplete and can not be searched.

      Comment

      • pankajit09
        Contributor
        • Dec 2006
        • 296

        #4
        Originally posted by RonB
        You can't

        A unc path is \\server(name or ip)\sharename\dir where dir is optional

        Without the sharename the unc path is incomplete and can not be searched.

        When I give the UNC path with only the IPADDRESS in the "run" box and press the enter button it shows all the shared folders.

        Comment

        • pankajit09
          Contributor
          • Dec 2006
          • 296

          #5
          Originally posted by ezechiel
          I don't know, but isn't it possible to put the directories of \\ipaddress in a list and then do a find in that list?

          But I don't know if this works (just starting with Perl):
          Code:
          my $homedir = "\\\\ipaddress";
          opendir (IMD, $homedir) or die "Couldn't find dir: IMD ($!)";
          my @thefiles= readdir(IMD);
          closedir(IMD);

          No it doesn't work if we give only the IPADDRESS.

          Comment

          • RonB
            Recognized Expert Contributor
            • Jun 2009
            • 589

            #6
            Originally posted by pankajit09
            When I give the UNC path with only the IPADDRESS in the "run" box and press the enter button it shows all the shared folders.
            That's because the "run box" is a Windows application which, when given a partial unc path, "knows" that it needs to make calls to 1 or more dll functions that can get the list of share names.

            Try doing it from the command line.
            Example:
            Code:
            C:\>dir \\10.100.0.118
            The filename, directory name, or volume label syntax is incorrect.
            
            C:\>dir \\10.100.0.118\c$
             Volume in drive \\10.100.0.118\c$ has no label.
             Volume Serial Number is 3019-C2D7
            
             Directory of \\10.100.0.118\c$
            
            02/11/2009  01:49 PM            18,791 021scan.txt
            02/11/2009  10:20 AM            19,141 021scan.txt.bak
            ...
            ...
            If you want, you could use Win32::API to call the dll functions that return the list of shares, however that's not as easy as you might think.

            Comment

            Working...