473,503 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem writing file in CGI script

1 New Member
Hi, this is my first post so please excuse any mistakes!

I'd like to write files using an upload script in my website, but I'm having problems. I don't seem to be able to write a file. Ive set up the following script to test this. It first reads a file successfully, then tries to write a file in the same directory. When run, the script stops at the line to open the file for writing without any errors. The permissions on the directory are 707, so I don't think this is the problem. Can anyone help me?

(www.thetimeband.com/cgi-bin/upload_file.cgi)

#!/usr/bin/perl -wT

use strict;
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);

use lib '.';
use timebandweb;

my $testread = $ENV{'DOCUMENT_ROOT'}."/misc/test.txt";
my $testwrite = $ENV{'DOCUMENT_ROOT'}."/misc/test1.txt";

timeband_header("testing");

timeband_wrapper_start();

print "Attempting to read $testread<br>\n";

open READFILE, "< $testread" or die "Unable to open $testread: $!\n";

while (<READFILE>) {
print "$_<br>\n";
}

close READFILE;

print "Attempting to write $testwrite<br>\n";

open WRITEFILE, "> $testwrite" or die "Unable to open $testwrite: $!\n";

print WRITEFILE "It worked...\n";

close WRITEFILE;

print "All done<br>\n";

timeband_wrapper_end();

timeband_footer();
Aug 19 '06 #1
1 2524
bharad
7 New Member
brab,

usually, scripts executed by webservers are run as user, "apache" or "nobody", as configured.

it is not enough for the end directory to have write permissions for this user, but the entire path should have write permissions. ensure you have it. alternatively, try if the program writes in /tmp to start with. if it does, it is clearly a permission issue.

-bharad
Aug 30 '06 #2

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

Similar topics

2
2199
by: Randy Jackson | last post by:
Hello all. Okay, this seems really stupid, but it's driving me up the wall. I have a simple script I've written to log some information to a text file. Everything seems to be okay, the code...
6
4721
by: Rami A. Kishek | last post by:
Hi - this mysterious behavior with shelve is just about to kill me. I hope someone here can shed some light. First of all, I have this piece of code which uses shelve to save instances of some...
2
4069
by: marco | last post by:
Hello, I having a problem creating directories with Python 2.3.4 (compiled with gcc 3.2.2, under Linux 2.4.20-31.9). I'm writing a plugin which works in the following way: GUI --...
7
3635
by: Navin | last post by:
hi, i am using the follwoing code to write a recordset to a csv file 'fcreateFile -file system object Do While Not oRs.EOF fcreateFile.Write(oRs.GetString(,1000,",",vbcrlf,"")) 'Write Login...
4
1530
by: Pekka Niiranen | last post by:
Hi, I am running Python script in W2K or in WinXP. The script is started from DOS prompt and writes text file to disk with codecs.open() in UTF8. The problem is: When script writes the file...
3
1526
by: koutoo | last post by:
I have a code that writes to 2 seperate files. I keep getting a "list index out of range" error. The strange part is that when checking the files that I'm writing too, the script has already...
1
1765
by: sbettadpur | last post by:
hello i am calling .exe file through my php script. i.e. using exec or system command, i am running exe file that exe file will create on txt file which contains who has logged into domain(i.e....
1
1926
by: sheldonlg | last post by:
I have inherited code with a TDC control. In this file, there are two javascripts of interest. One of these is a function, filter(), which is inside <script language=javascript></script>. The...
3
1713
by: karthikchittur | last post by:
Hello scripters Requirement: I am trying to write a perl script that manipulate a html file. Both the html file and the script are placed at central server. I have scheduled one more script in...
0
7201
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,...
0
7083
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...
1
6988
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...
0
7456
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...
1
5011
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4672
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...
0
3166
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...
0
3153
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
379
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.