CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Creating a file online and writing to it.

 



Maebius
Novice

Jun 6, 2000, 8:44 AM

Post #1 of 5 (757 views)
Creating a file online and writing to it. Can't Post

I am attempting to create a multi-user game section on my webpage, and am storing each 'player' information in a seperate file.

Example, registered players database looks like this (login::password::security):
nflory::x4QuB2::admin
maebius::temp1::user
...

Then there are seperate files containing other details for a particular person (address, email, account status, etc)
nflory.dat
maebius.dat

As this stands, I have new users register via your standard form-mailer, and then I create the */dat file and set the permissions manually.

My question and current headache is wondering if there were a way to create the files on-the-fly, or somehow alter my basic thoughts so that I could automate the process. I've pondered options, but so far my brain is fried from the rest of my programming duties at work.

Thanks in advance for any advice or helpful comments!
-Maebius@dreamscape.com


monocle
User

Jun 5, 2000, 10:04 PM

Post #2 of 5 (757 views)
Re: Creating a file online and writing to it. [In reply to] Can't Post

open (FH, ">$filename"); will create a new file with $filename and open it for writing. so...when the user submits the form, you capture the desired name of the file and use the line above to create it, then print FH "WHAT EVER INFO YOU WANT TO PRINT";. Be sure to close(FH); when you are finished writing to the file.

To set the permissions on a file use chmod(0777, $filename);

Hope this helps.

Monocle
Hear great techno music by Monocle at http://www.mp3.com/monocle


Maebius
Novice

Jun 6, 2000, 11:43 AM

Post #3 of 5 (757 views)
Re: Creating a file online and writing to it. [In reply to] Can't Post

Thanks for the reply Monocle!

I tried your suggestions, and they work if I run this script locally. However, if I upload it to the server, I get the following error page back:
-----------------
Forbidden
You don't have permission to access /ntflew/RPG_signup.cgi on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
-----------------------

If I set the filename to be an already existing file (that has the permission CHMODs already set), I still get the 'Forbidden', but I do not get the 404 not Found message.

Apparently, I'm not able to write to files on the server with this script. I've whipped up a very simple script that just opens a file and prints to it. All hard-coded and only a few lines, but it still produces the Forbidden message.

Could this perhaps be the result of being a simple user of my ISP's CGI capabilities and not being an admin to the server?

If you go to www.dreamscape.com/ntflew/everthor.htm
you can see an example of my script-in-progress. The one i'm working on with this post is the Sign Up Now link.
the password script uses nflory/nflory as the login/password. (just in case you want to see it)

As always, any help is appreciated in advance. Smile
-maebius@dreamscape.com


monocle
User

Jun 7, 2000, 7:10 AM

Post #4 of 5 (757 views)
Re: Creating a file online and writing to it. [In reply to] Can't Post

That one I don't know. I am not very learned on the server stuff. Just to state the obvious...make sure you chmod the script properly.
<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">quote:</font><HR>
Forbidden
You don't have permission to access /ntflew/RPG_signup.cgi on this server.
<HR></BLOCKQUOTE>
To me, this means you can't run the script. This message says nothing to me about not being able to create and print to a file.

But like I said, I don't know too much about servers.

Monocle
Hear great techno music by Monocle at http://www.mp3.com/monocle


rottweiler
Deleted

Jun 9, 2000, 1:55 AM

Post #5 of 5 (757 views)
Re: Creating a file online and writing to it. [In reply to] Can't Post

I am not a wiz kid but normally if you want to insert info into a file on a server you need to have r/w permissions. you can give this by taking the directory and chmod it to 777 and this allows data entry. Of course the server may be set not to allow r/w on directories and in that case you should talk to your host company or move to another like the ones I use.

Hope this helps sort it

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives