in reply to problem in mkdir

In line 32, 58, and 59, you're calling mkdir, but not checking the "return value" (which is to say, not checking for success or failure). It's very important to check for failure, and if failure occurs, inspect the contents of the special variable "$!" to see what went wrong. Otherwise we're all just going to be guessing.

So, for example, on line 32, change to:

mkdir "/var/www/html/piRNA_html/UNAFold/output/$temp2/$temp1", 0775 or die "Failed to create directory ..../$temp2/$temp1: $!";

Once you know what went wrong 3/4ths of the battle is won. We could wade through the code, ask a bunch of questions, and so on. But unless you're taking advantage of Perl's ability to provide clues you haven't done your own due diligence yet. :)


Dave

Replies are listed 'Best First'.
Re^2: Problem in creating Directory
by MVRS (Acolyte) on Dec 02, 2011 at 12:55 UTC

    after adding $! , am getting the following error in my gi

    Software error: Cannot make directory /var/www/html/piRNA_html/UNAFold/output/10010 , errorwas:Permission denied at /var/www/html/piRNA_html/UNAFold/mkdirtest.cgi line 39.

    i couldnt understand , though 0777 permission given , y its giving error about permission, please reply me in this

      When you create a file or directory, you can define the permissions for the item you are going to create. These are the 0777 permissions given by You.

      As creating a new directory is nothing else but writing an entry into the directory above, you need write permissions for /var/www/html/piRNA_html/UNAFold/output.

      The user that needs those permissions is the cgi user, the script will run under.

      Here You can find some hints on CGI programming

      The error tells you "You do not have the permission to create the directory", while the permission you give means "after creating the directory, give it this permission". These two permissions are totally unrelated.
      You've reported at least two completely different errors in this thread, "file exists", and "permission denied". For "permission denied", do this:
      ls -ld /var/www/html/piRNA_html/UNAFold/output

      What are the permissions on the directory? Do you (or the user this script is running under) have write permission in the directory?

Re^2: Problem in creating Directory
by MVRS (Acolyte) on Dec 02, 2011 at 06:37 UTC
    Thanks for the reply dave, yes ur ryt i havent done proper deligence, becoz am new to perl , and my perl knowledge is not upto the mark , when i changed accordingly its giving following error Failed to createeate directory /var/www/html/piRNA_html/UNAFold/output//: File exists at /var/www/html/piRNA_html/UNAFold/mkdirtest.cgi line 39.

      Now go to your linux prompt and type the following:

      mkdir mytest mkdir mytest

      You'll get the following error message:

      mkdir: cannot create directory mytest: File exists

      You can go ahead and rmdir that mytest directory now, and then ask yourself why you're trying to create a directory that already exists.


      Dave

      A reply falls below the community's threshold of quality. You may see it by logging in.

      The error message just tells You that the directory $somepath/output exists. Your variables $temp1, $temp2 seem to have been empty (see the trailing slashes in the error message).

      Besides the push statement in line 27 declares a second array @folder_names.

      You should really uncomment the "use strict" like already said. This will help You find and correct errors like this one.