Solved

Open file to write

Posted on 1998-11-25
5
141 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
  • 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 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now