Web Hosting Talk







View Full Version : Creating Directories in Perl


Chachi
07-11-2002, 07:27 AM
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 :(

F.N
07-11-2002, 07:39 AM
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:


#!/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();
}

Chachi
07-11-2002, 07:42 AM
Yes I have. That doesn't seem to be the problem ...

YUPAPA
07-11-2002, 07:43 AM
COME ON ASK ME PERL!

why do you need a subroutine anyway? :confused:


#!/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__



... :)

F.N
07-11-2002, 07:47 AM
wowee, 2 replies while I was editing...


__________________
Hi, my name is Yupapa Bahamama.
FORK FORK, Where are you? :fork:


Are the one responsible for all those FORK BOMBS crashing server?

YUPAPA
07-11-2002, 07:48 AM
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? :stickout

F.N
07-11-2002, 07:51 AM
I like oranges, but not from phantom fork bombers :D

YUPAPA
07-11-2002, 07:53 AM
Why did you say I am a boobie?

Chachi
07-11-2002, 07:56 AM
Thanks Yupapa, that works!! :D Now I'll just go get rid of the "because yupapa says" and "Thank you Yupapa" bits from the code... you two have fun!!!

YUPAPA
07-11-2002, 07:58 AM
okay! come back to play with me soon!