...

View Full Version : mkdir doesn't work and no error in logs.



bazz
06-26-2009, 03:52 AM
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.



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

oesxyl
06-26-2009, 04:13 AM
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.



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

bazz
06-26-2009, 04:22 AM
sorry, I am tired. the correct script is like this



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. :confused:

bazz
06-26-2009, 04:31 AM
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

oesxyl
06-26-2009, 04:34 AM
sorry, I am tired. the correct script is like this



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. :confused:
I apologize, I missread your post, you already said that is no message in your first post.
try this:


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

bazz
06-26-2009, 06:30 AM
Thanks oesxyl but, unfortunately, that isn't working either.

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

bazz

oesxyl
06-26-2009, 06:39 AM
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

bazz
06-26-2009, 02:20 PM
Hi oesxyl,

I checked the error logs and it outputs this:


[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

oesxyl
06-26-2009, 02:54 PM
Hi oesxyl,

I checked the error logs and it outputs this:


[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

bazz
06-26-2009, 03:05 PM
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

bazz
06-26-2009, 03:10 PM
OK, puttyed the server and got this as the permissions for that dir (vhosts)



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

oesxyl
06-26-2009, 03:34 PM
OK, puttyed the server and got this as the permissions for that dir (vhosts)



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

bazz
06-26-2009, 03:38 PM
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

oesxyl
06-26-2009, 04:36 PM
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

bazz
06-27-2009, 02:18 AM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum