Results 1 to 10 of 10
  1. #1
    Join Date
    Jun 2002
    Posts
    1,874

    Creating Directories in Perl

    Hi,

    I'm having problems creating directories on my web hosting account using scripts. Basically I have this coding in a .pl file:

    #!/usr/bin/perl
    $new_dir = "newdir"
    $perm = 755;
    makeDir();

    sub makeDir {
    mkdir ($new_dir,$perm) or "Error making Directory ($new_dir)\n";
    exit();
    }

    Is there anything wrong with the coding? It doesn't seem to work for me

  2. #2
    Join Date
    Mar 2002
    Posts
    231
    Have you checked your permission?

    ie. the permission of the directory in which the new dir is to be created. This dir needs to have world writeable (unless you're running thru suExec/wrapper).

    [edit]
    then again, it could be your code:

    Code:
    #!/usr/bin/perl 
    $new_dir = "newdir" 
    $perm = 755; 
    makeDir(); # NOT CORRECT
    #should be:
    &makedir;
    
    sub makeDir { 
    mkdir ($new_dir,$perm) or "Error making Directory ($new_dir)\n"; 
    exit(); 
    }

  3. #3
    Join Date
    Jun 2002
    Posts
    1,874
    Yes I have. That doesn't seem to be the problem ...

  4. #4
    Join Date
    May 2001
    Location
    HK
    Posts
    3,082
    COME ON ASK ME PERL!

    why do you need a subroutine anyway?

    Code:
    #!/usr/bin/perl
    use strict;
    
    my $new_dir	=	q(/path/to/the/new/dir);		# You don't have to type in the full path and that will create the dir where your script is stored
    my $perm	=	0755;
    
    # I think you are running this via your web browser, if not get rid of content-type below
    
    print "Content-Type: text/html\n\n";
    
    
    if(!mkdir($new_dir,$perm)) {
    	print "Fail to make directory $new_dir because yupapa says $!\n";
    } else {
    	print q(WOAH, the directory is created!! Thank you Yupapa);
    }
    
    __END__
    ...

  5. #5
    Join Date
    Mar 2002
    Posts
    231
    wowee, 2 replies while I was editing...

    __________________
    Hi, my name is Yupapa Bahamama.
    FORK FORK, Where are you?
    Are the one responsible for all those FORK BOMBS crashing server?

  6. #6
    Join Date
    May 2001
    Location
    HK
    Posts
    3,082

    *

    Originally posted by tn3
    wowee, 2 replies while I was editing...



    Are the one responsible for all those FORK BOMBS crashing server?
    Hi, nice to meet you. I am Yupapa... like my orange?

  7. #7
    Join Date
    Mar 2002
    Posts
    231
    I like oranges, but not from phantom fork bombers

  8. #8
    Join Date
    May 2001
    Location
    HK
    Posts
    3,082
    Why did you say I am a boobie?

  9. #9
    Join Date
    Jun 2002
    Posts
    1,874
    Thanks Yupapa, that works!! Now I'll just go get rid of the "because yupapa says" and "Thank you Yupapa" bits from the code... you two have fun!!!

  10. #10
    Join Date
    May 2001
    Location
    HK
    Posts
    3,082
    okay! come back to play with me soon!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •