?
Solved

Open file to write

Posted on 1998-11-25
5
Medium Priority
?
147 Views
Last Modified: 2010-03-04
I have the following script on one of my NT servers.  It is accessed from an html form.  It prints out the 1st and 3rd files, but it can't open the second one.  It works on other servers.  The server admin says he has all of the permissions set correctly.  Why not?

#!c:\perl\bin\perl.exe

$basdir = "d:\\websites\\botten\\cgi-bin\\";
$abc = $basdir . "test.txt";
$def = $basdir . "iden.txt";
print "Content-type: text/html\n\n";

open(NAM2, "$def") || print "a can't open<br>";
$input = <NAM2>;
print "$input<br>";
close NAM2;

open(NAM2, ">$abc") || print "b can't open<br>";
print NAM2 ("abcdefgh\n");
close NAM2;

open(NAM2, "$abc") || print "c can't open<br>";
$input = <NAM2>;
print "$input<br>";
close NAM2;
exit;
0
Comment
Question by:donb1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 5

Expert Comment

by:b2pi
ID: 1206623
Try changing your open lines to:

open(NAM2, ">$abc") || print "b can't open ($!)<br>";
print NAM2 ("abcdefgh\n");
close(NAM2);


On the other hand, if you were a web-site administrator, would _YOU_ give every user write access to the cgi-bin (and if so, how would you prevent someone evil from uploading a perl program to your cgi-bin, and using it to delete everything else?)
0
 

Author Comment

by:donb1
ID: 1206624
b2bi -
The script isn't the problem.  It works on 2 other NT servers.  The problem is in the NT settings at the server.  Also cgi-scripts aren't of much value if you can't write to a file.  How is someone going to upload a file to the server without a password??
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1206625
b2pi suggestion will at least tell you the reason, anyhow.

If you know that the permissions are the problem, could you please verify
If the user under which this cgi runs has change and create permissions in
both, the directory and the corresponding share.
0
 

Author Comment

by:donb1
ID: 1206626
Permissions are denied, so I will need to wait until after the ISP returns from the long week-end.  I would think that Microsoft would give some kind of support to ISPs running NT so that they would know how to set up permissions.
Thanks
0
 
LVL 5

Accepted Solution

by:
b2pi earned 200 total points
ID: 1206627
The reason I simply didn't say that the permissinos didn't exist on that directory is because you explicitly stated that the permissions were set correctly.  In fact, I'd agree with him. You don't have to wait.  Create a directory someplace else, and allow write access to all.  Then, write to that directory.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question