using perl to create files

Started by
1 comment, last by lukeyes 20 years, 8 months ago
Hello, I''m trying to write a CGI script that will take a username and create a new data file that is the "username.txt" so that it can write the data for that user. I use the open command in Perl $cfilename = $username.".txt"; open(UFILE, ">$cfilename"); # do stuff the open command is supposed to create a file if it does not exist, but when I look in the directory, there is no new file created. I read some hints that I would have to change the permissions of my cgi-bin directory to allow the script to create new files in the directory, however, I tried setting different permissions and didn''t run into anything that worked. has anyone else had this problem before and can tell me how I can fix it? thanks in advance.
Advertisement
Check if open fails or so.
open(UFILE, ">$cfilename") or die "$!";

The $! variable holds an error message which is set by open if it fails. If you run it as a CGI script through a web page, the message should show up in the web server error log (that''s what it does for me, using Apache).
nope, for some reason if I check to see if it works, as in

if (open(blah blah blah))
# do file code
else
# display error message

it always does the file code even if the file wasn''t created. no error messages come up in the logs, just no file being created.

written as a perl file and ran in windows, it works fine. but CGI under Linux, it doesn''t.

c''mon guys, keep me from turning over to the dark side of Windows, keep me using Linux.

Luke.

This topic is closed to new replies.

Advertisement