[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 153
  • Last Modified:

Open file to write

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
donb1
Asked:
donb1
  • 2
  • 2
1 Solution
 
b2piCommented:
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
 
donb1Author Commented:
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
 
ahoffmannCommented:
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
 
donb1Author Commented:
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
 
b2piCommented:
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

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now