473,809 Members | 2,710 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mkdir is failing when script is called by apache, but not from shell???

1 New Member
Hi people,

I'm trying to get a script to create a few directories on a webserver, and unzip a file or two.

my script works fine locally, when accessed via shell.

When accessd via apache, it fails :(

What to do?

Here's my code:

mkdir($School, 0755);
chdir($School) || die( "Cannot chdir (1)" );

the $School directory does not exist! It was not made :( I checked the files on my hard disk, it was never created. But it WAS Created if I run the script locally.

What must I do?

BTW, the server I'mg oing to install on, I'm not sure how much privileges I'll be allowed on it. My client will help me all they can, as they aren't beaureaucratic, but it is a commercial web server and not based on my home computer, so I have less control over it.
May 31 '07 #1
2 1966
prn
254 Recognized Expert Contributor
It's almost certainly a permissions issue. When you run the script (as yourself) it works, but when Apache tries to run the script (probably running as the user "nobody") it fails because "nobody" doesn't have write permission for the directory where you are trying to create the new directory.

Check that out. You will probably need to change the file permissions or ownership of the upper directory.

HTH,
Paul
May 31 '07 #2
miller
1,089 Recognized Expert Top Contributor
Greetings boytheo,

It appears that you've cross posted on a lot of different forum sites. This is typically frowned upon and will often net you less help in the end because cross-posters notoriously do not come back and check for answers.

Nevertheless, the answer is simple. The permissions for the directory you're creating under are inadequate for the user the apache server is running on. This is fixable.

Whenever you do a mkdir command, include an "or die" as this will tell you when an error occurs.

perldoc mkdir

Expand|Select|Wrap|Line Numbers
  1.  mkdir($School, 0755) or die "mkdir failed: $!";
  2.  
- Miller
May 31 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
9754
by: LRW | last post by:
Sorry to crosspost, but I have no idea if this is more a PHP question of general Linux question. I have a script that makes changes to image files, montages them into a jpg, and creates a Web page with that image. It starts with someone from our graphics dept. who I set up to copy the image files over to the Linux server with SAMBA. The files gain the owner/group of "nobody" and permissions of 744.
7
4237
by: fingermark | last post by:
i have the make.php located on my server. the only line of code is mkdir("/home/foouser/public_html/newdir", 0755);. now /home/foouser/public_html is "drwxr-xr-x 7 foouser foouser". with just that code i get permission errors. i am running make.php from a remote machine. so how can i get mkdir to create a directory in /home/foouser/public_html without chmodding anything to 777. would adding some type of authentication system to...
10
2161
by: lawrence k | last post by:
I've got a script called makeRss.php. It works fine if I try to open it with my browser. It makes an RSS feed for every page on my site. You can see it working here: http://www.autostratus.com/index.php?whatPage=makeRss It does just what I want it to do. However, I need for this script to get called every 15 minutes. So I set it up as a cron job. And cron doesn't like calling this thing. Cron
30
7714
by: MikeC | last post by:
Good People, I'm writing a backup utility that uses a chdir() to go into the source directory (in which the files reside that I want to back up), so I don't want to use chdir() to get into the target directory (where the backup copies will be kept, on another drive). I can successfully test whether the target directory exists or not using findfirst(), but if it doesn't, I wanted to create it using mkdir(), but it doesn't like the path...
8
24538
by: vj | last post by:
How do I do the following unix command: mkdir -m770 test with the os.mkdir command. Using os.mkdir(mode=0770) ends with the incorrect permissions. Thanks, VJ
4
2095
by: dbee | last post by:
Right. I've got a really, really annoying/difficult/time consuming problem with my development environment. I'm using django to build a web app with paypal integration. My server is hosted remotely, and it is receiving IPN (payment notifications) POST requests from Paypal. I've checked on google and irc and this is my last shot at solving this before I go mad ... :-( The problem is that I can't debug those POST requests. Browser...
10
8337
by: gh | last post by:
I have a short JS program that runs fine from the command line: #!/usr/bin/java org.mozilla.javascript.tools.shell.Main print("Hello World"); I saved it as HelloWorld.js. (It's the shabang that makes it a JavaScript program, not the .js.) However, if I start it from Safari or Firefox, I get the following message in the log:
2
1994
by: _q_u_a_m_i_s's | last post by:
Hy, i encountered a weird problem on a server running php5, and apache. Seems like i cannot create folders that end with "/". for example: mkdir("test/") will fail mkdir("test") will work Is there any issue with mkdir that i don`t know about? or safe_mode affects this in any way? The problem is that mkdir is called in lots of different places in the
10
6983
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration of section c. Not sure where went wrong as the web page displayed internal server error. Also, what is the error 543? and error 2114. Where to find the list of errors in websites as it is not the standard apache error. I could not find...
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10387
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10120
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5689
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.