Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 15 of 15
  1. #1
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts

    mkdir doesn't work and no error in logs.

    Trying to create a directory via my script rather than through plesk, but it doesn't happen and there is no error message in the server logs.

    Code:
      use Cwd;
      my shortened web_url ='example.com'; # without the www.
      my $newdir = '/var/www/vhosts/'; 
      chdir($newdir) || die "can't change dir to $newdir $!";
    
      print 'New Current directory: ', cwd(), "\n\n"; # seems OK
       
      mkdir "$shortened_web_url", 0755 || die "can't create dir $!";
    The server permission have been chnaged to allow this task. what am I getting wrong?

    bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by bazz View Post
    Trying to create a directory via my script rather than through plesk, but it doesn't happen and there is no error message in the server logs.

    Code:
      use Cwd;
      my shortened web_url ='example.com'; # without the www.
      my $newdir = '/var/www/vhosts/'; 
      chdir($newdir) || die "can't change dir to $newdir $!";
    
      print 'New Current directory: ', cwd(), "\n\n"; # seems OK
       
      mkdir "$shortened_web_url", 0755 || die "can't create dir $!";
    The server permission have been chnaged to allow this task. what am I getting wrong?

    bazz
    post the message please and check to have underline instead of space in "my shortened web_url"( 2nd line), probably a typo here.

    best regards

  • #3
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    sorry, I am tired. the correct script is like this

    Code:
    use Cwd;
      my $shortened_web_url ='example.com'; # without the www.
      my $newdir = '/var/www/vhosts/'; 
      chdir($newdir) || die "can't change dir to $newdir $!";
    
      print 'New Current directory: ', cwd(), "\n\n"; # seems OK
       
      mkdir "$shortened_web_url", 0755 || die "can't create dir $!";
    mo error message to post and no directory is created.
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #4
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    I should add that this directory is to be the root dir for a domain. I thought that changing the server permissions, I would remove the problem of adding a dir above root.

    bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #5
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by bazz View Post
    sorry, I am tired. the correct script is like this

    Code:
    use Cwd;
      my $shortened_web_url ='example.com'; # without the www.
      my $newdir = '/var/www/vhosts/'; 
      chdir($newdir) || die "can't change dir to $newdir $!";
    
      print 'New Current directory: ', cwd(), "\n\n"; # seems OK
       
      mkdir "$shortened_web_url", 0755 || die "can't create dir $!";
    mo error message to post and no directory is created.
    I apologize, I missread your post, you already said that is no message in your first post.
    try this:
    Code:
    my $newdir = '/var/www/vhosts/';
    my $shortened_web_url ='example.com'; # without the www.
    my $tomake = $newdir . $shortened_web_url; # absolute path
    my $result = qx(mkdir -p $tomake);
    print $result if $result ne '';
    $result = qx(chmod 0755 $tomake);
    print $result if $result ne '';
    of course add strict, warn at top. If this work I don't see any reason why your original script could fail.

    best regards

  • #6
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    Thanks oesxyl but, unfortunately, that isn't working either.

    I'll likely have to stick with plesk until I can work it out.

    bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #7
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by bazz View Post
    Thanks oesxyl but, unfortunately, that isn't working either.

    I'll likely have to stick with plesk until I can work it out.

    bazz
    it must output a error message, the content of $result. Do you run this from command line or as cgi script?

    best regards

  • #8
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    Hi oesxyl,

    I checked the error logs and it outputs this:
    Code:
    [Fri Jun 26 05:32:43 2009] [error] [client 86.29.85.82] mkdir:
    [Fri Jun 26 05:32:43 2009] [error] [client 86.29.85.82] cannot create directory `/var/www/vhosts/abcd.com'
    [Fri Jun 26 05:32:43 2009] [error] [client 86.29.85.82] : Permission denied
    I don't get this because the isp has changed the permissions and they say that apache has read,write, execute permissions.
    bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #9
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by bazz View Post
    Hi oesxyl,

    I checked the error logs and it outputs this:
    Code:
    [Fri Jun 26 05:32:43 2009] [error] [client 86.29.85.82] mkdir:
    [Fri Jun 26 05:32:43 2009] [error] [client 86.29.85.82] cannot create directory `/var/www/vhosts/abcd.com'
    [Fri Jun 26 05:32:43 2009] [error] [client 86.29.85.82] : Permission denied
    I don't get this because the isp has changed the permissions and they say that apache has read,write, execute permissions.
    bazz
    could be few reasons:
    - do you use -T in your perl script, tainted mode
    - permission settings are per directory, probably you don't have write permision in /var/www/vhosts/. Check permision with a ftp client, from a file manager or run 'ls -l' there.
    I don't have something else in mind at this moment but is possible to exists other reasons.

    best regards

  • #10
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    Thanks oesxyl,

    I don''t use -T in this script

    The directory which I want to write to is above web root so I shall get putty working later and try the ls -l command in vhosts. maybe that'll shed light on it.

    bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #11
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    OK, puttyed the server and got this as the permissions for that dir (vhosts)

    Code:
    drwxrwxr-x+ 31 root      root 4096 Jun 26 03:53 vhosts
    To me, that says the permissions are correct. so what else could cause the problem?


    bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #12
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by bazz View Post
    OK, puttyed the server and got this as the permissions for that dir (vhosts)

    Code:
    drwxrwxr-x+ 31 root      root 4096 Jun 26 03:53 vhosts
    To me, that says the permissions are correct. so what else could cause the problem?

    bazz
    apache run in his own group, probably nobody if is a redhat linux, and cgi scripts run in the same group so probably don't have permision to write there.

    best regards

  • #13
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    So, if I put the specific sub-routine of my script into the /var/www/ directory and require it to run from the main script in my cgi-bin, might that work?

    I shall try it but, I wondered if you guys knew the answer so I wouldn't go down a dead end.

    bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #14
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by bazz View Post
    So, if I put the specific sub-routine of my script into the /var/www/ directory and require it to run from the main script in my cgi-bin, might that work?

    I shall try it but, I wondered if you guys knew the answer so I wouldn't go down a dead end.

    bazz
    I'm not sure but I guess will not work and if work seems unsafe from my point of view.

    best regards

  • #15
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    Finally got it working. After a review by the isp, they realised that they had to give permissions to the user rather than to apache. So, they tell me, my scripts on my domain can create write to the vhosts dir but nothing else can.


    Thanks for your help oesxyl.
    bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link


  •  

    Posting Permissions

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