Results 1 to 10 of 10
Thread: Creating Directories in Perl
-
07-11-2002, 07:27 AM #1Web Hosting Master
- 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
-
07-11-2002, 07:39 AM #2Junior Guru
- 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(); }
-
07-11-2002, 07:42 AM #3Web Hosting Master
- Join Date
- Jun 2002
- Posts
- 1,874
Yes I have. That doesn't seem to be the problem ...
-
07-11-2002, 07:43 AM #4Web Hosting Master
- 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__
-
07-11-2002, 07:47 AM #5Junior Guru
- Join Date
- Mar 2002
- Posts
- 231
wowee, 2 replies while I was editing...
__________________
Hi, my name is Yupapa Bahamama.
FORK FORK, Where are you?
-
07-11-2002, 07:48 AM #6Web Hosting Master
- 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?
-
07-11-2002, 07:51 AM #7Junior Guru
- Join Date
- Mar 2002
- Posts
- 231
I like oranges, but not from phantom fork bombers
-
07-11-2002, 07:53 AM #8Web Hosting Master
- Join Date
- May 2001
- Location
- HK
- Posts
- 3,082
Why did you say I am a boobie?
-
07-11-2002, 07:56 AM #9Web Hosting Master
- 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!!!
-
07-11-2002, 07:58 AM #10Web Hosting Master
- Join Date
- May 2001
- Location
- HK
- Posts
- 3,082
okay! come back to play with me soon!