473,473 Members | 2,269 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem writing to a file from a perl website

6 New Member
I have a Perl-driven website on a windows 2003 server. I have configured the IIS and have set the permissions on the Home Directory tab to Read, Write and my Execute Permissions are set to "Scripts and Executable."

I have gotten the site to work but my problem is, when I run the below code from my web browser, I do not see a file called "data.txt" in the same directory. When I execute this from the console, it works just fine. What am I doing wrong?? Is there anything else that I need to set?

Any help would be appreciated!

Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. open (MYFILE, '>>data.txt');
  3. print MYFILE "this is a test\n";
  4. close (MYFILE);
  5.  
  6. print "HTTP/1.0 200 OK\n";
  7. print "Content-Type: text/html\n\n\n";
  8. print <<html_end;
  9. <html>
  10. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  11. <html>
  12. <head>
  13. <meta http-equiv="Content-Type" content="text/html; charset=iso-88959-1">
  14. </head>
  15. <body>
  16. <p>Writing to a file...complete</p>
  17. </body>
  18. </html>
  19. html_end
  20.  
Feb 15 '08 #1
3 1632
numberwhun
3,509 Recognized Expert Moderator Specialist
I have a Perl-driven website on a windows 2003 server. I have configured the IIS and have set the permissions on the Home Directory tab to Read, Write and my Execute Permissions are set to "Scripts and Executable."

I have gotten the site to work but my problem is, when I run the below code from my web browser, I do not see a file called "data.txt" in the same directory. When I execute this from the console, it works just fine. What am I doing wrong?? Is there anything else that I need to set?

Any help would be appreciated!

Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. open (MYFILE, '>>data.txt');
  3. print MYFILE "this is a test\n";
  4. close (MYFILE);
  5.  
  6. print "HTTP/1.0 200 OK\n";
  7. print "Content-Type: text/html\n\n\n";
  8. print <<html_end;
  9. <html>
  10. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  11. <html>
  12. <head>
  13. <meta http-equiv="Content-Type" content="text/html; charset=iso-88959-1">
  14. </head>
  15. <body>
  16. <p>Writing to a file...complete</p>
  17. </body>
  18. </html>
  19. html_end
  20.  
have you checked the cgi-bin directory where this script is most likely residing? Also, after the opening of the file, test to make sure it worked.

Expand|Select|Wrap|Line Numbers
  1. open (MYFILE, '>>data.txt') or die "Cannot open file:  $!";
  2.  
That way, it gives you the error if it has a problem.

So that you are able to see the errors, also add the following:

Expand|Select|Wrap|Line Numbers
  1. use CGI::Carp qw(fatalsToBrowser);
  2.  
Feb 15 '08 #2
bpejman
6 New Member
Thank you so much for replying. My script does not reside under cgi-bin. It's actually under wwwroot folder. I do know that the script does get executed but as I suspected, I'm running into permission issues.

I did what you mentioned, by the way, thanks for that! and added
Expand|Select|Wrap|Line Numbers
  1. CGI::Carp qw(fatalsToBrowser);
and surely it came back saying "Cannot Open file...Permission denied"

I don't believe I would need to set the permissions on the NTFS side. Even though I did and still did not resolve my problem. Maybe I need to stop and start the webserver for the permissions to kick in???

Not sure what to do

have you checked the cgi-bin directory where this script is most likely residing? Also, after the opening of the file, test to make sure it worked.

Expand|Select|Wrap|Line Numbers
  1. open (MYFILE, '>>data.txt') or die "Cannot open file:  $!";
  2.  
That way, it gives you the error if it has a problem.

So that you are able to see the errors, also add the following:

Expand|Select|Wrap|Line Numbers
  1. use CGI::Carp qw(fatalsToBrowser);
  2.  
Feb 15 '08 #3
bpejman
6 New Member
Ok, I figured it out. I set the directory permissions on the wwwroot and Inetpub to Write and it worked. The directory permissions were inherited which never really made it up to the directory that I had my script in. Now it all works!

:)

Thank you so much for replying. My script does not reside under cgi-bin. It's actually under wwwroot folder. I do know that the script does get executed but as I suspected, I'm running into permission issues.

I did what you mentioned, by the way, thanks for that! and added
Expand|Select|Wrap|Line Numbers
  1. CGI::Carp qw(fatalsToBrowser);
and surely it came back saying "Cannot Open file...Permission denied"

I don't believe I would need to set the permissions on the NTFS side. Even though I did and still did not resolve my problem. Maybe I need to stop and start the webserver for the permissions to kick in???

Not sure what to do
Feb 15 '08 #4

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

Similar topics

5
by: mark1822 | last post by:
Hi, I am trying to figure out if I should learn C and C++ to write CGI programs, or if I should just use PHP for my web site. I want to write a high traffic website that would call executibles...
1
by: smsabu2002 | last post by:
Hi, I am facing the build problem while installing the DBD-MySql perl module (ver 2.9008) using both GCC and CC compilers in HP-UX machine. For the Build using GCC, the compiler error is...
1
by: von | last post by:
I am trying to write a single piece of data (that is generated from a Javascript) to a text file on my server via a Perl script. The Javascript is setup so that I can display the required data on...
3
by: Procor | last post by:
Hello, i'm new with perl. I want to read a file and display this when visiting my website : In my browser : http://www.website.nl/displayfile.pl =================== #!/usr/local/bin/perl...
25
by: Xah Lee | last post by:
Python Doc Problem Example: gzip Xah Lee, 20050831 Today i need to use Python to compress/decompress gzip files. Since i've read the official Python tutorial 8 months ago, have spent 30...
1
by: brabster | last post by:
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...
0
by: deacon57 | last post by:
FYI - If you are a computer scientist (or geek), this post may be for you. I wanted to log any search keywords, etc that are used on my site. I created a simple program that logs search terms...
12
by: jcor | last post by:
Hi, I'm using Ubuntu 7.04. I'm writing a sript that sends files via ftp for several destinations. So far I used Net::FTP and it worked fine. My problem is that I need to send files via SFTP...
6
by: Keith Lee | last post by:
All: I am attempting to compile the perl module Device::SerialPort and get this error during make -- Manifying blib/man3/Device::SerialPort.3pm Can't open blib/man3/Device::SerialPort.3pm for...
0
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
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...
1
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...
1
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
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
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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.