in reply to Server access denied when checking for files

'Access denied' could mean any of a number of things:

Each of these errors may result in different things needing to be done to fix them. It would be useful for you post the exact error message, and the script that you're trying to use (as the error messages may be generated from the script and not the OS, and/or refer to line numbers within the script)

  • Comment on Re: Server access denied when checking for files

Replies are listed 'Best First'.
Re^2: Server access denied when checking for files
by bobdole (Beadle) on Apr 25, 2005 at 23:56 UTC
    I know the paths to the folders are correct becuase if I take out the part where it actually moves the folders it works fine.

    Here is the command line:
    C:\Documents and Settings\Tim\My Documents\test1>perl readdir.plx
    Access is denied.

    Here is the code
    #!/usr/bin/perl $dirtoget="\\\\Server\\Bankpro"; #directory to +read folders opendir(IMD, $dirtoget) || die("Cannot open directory"); #o +pen directory @thefiles= readdir(IMD); #store all files a +nd folders in directory into an array closedir(IMD); #close directory open (filenames, "dissmissed2.txt") || die ("Could not open file. <br> + $!"); #open list of file names $text = <filenames>; #read in one line +from txt file $defaultdir = "\\\\Server\\Bankpro"; # Directo +ry containing original folders $destinationdir = "\\\\Server\\BPdismis"; # Direct +ory to copy folders to foreach $f (@thefiles) #for each file i +n the directory { unless ( ($f eq ".") || ($f eq "..") ) #dont move + unless its a file of folder { while ($text){ #while there is a li +ne of text $text =~ s/\s+$//; #strip off whitesp +ace, newline and tabs system qq(move /y "$defaultdir/$text" "$destinationdir"); +#move files to diffrent directory $text = <filenames>; #read in next +line from file } } } close (filenames); #close list of files

      Then from the sounds of it, you don't have permission to write to the directories in which you're trying to move the files. There's also a slight chance that you don't have permission to modify the directory that you're attempting to move the files from (as you're effectively removing an item from that directory)

      Can you move files from the command line, without using perl? If so, is the Perl script running under any different permissions than your normal permissions?

        I am not at the office right now so I can not check if I can move folders from the command line without using perl or not, I will first thing in the morning, but how would I check or run the perl script's permissions?

        Thanks for the help.
      I was trying to understand what you are attempting to do, but don't at all. Is this being run as a CGI; if not, why does the the error message for the first open have <br>? (It won't print to the browser because there is no content type line.) What does the comment "#dont move unless its a file of folder" mean? What do the files listed in dissmissed2.txt have to do with the entries in @thefiles? I don't understand what your last foreach loop is doing; it looks like for each $f in @thefiles (except . and ..), you are trying to do the same operations on the files listed in dismissed2.txt (but it looks like it will only be successful the first time.); isn't this latter file always the same independent of the value of $f?
      If I'm just being dense, please excuse...it's getting to be past my bedtime; but I've been looking at this for a while, and I can't make any sense of it.
      chas
      You don't check every operation for success. You should check that readdir worked:
      @thefiles= readdir(IMD) or die "can't readdir: $!";
      And the most important part : check that you can actually "move" the files:
      system qq(move /y "$defaultdir/$text" "$destinationdir") or die "can't + move the file: $!";
      to understand where exactly the script fails.