|
Joined: Sep 2000
Posts: 138
Member
|
Member
Joined: Sep 2000
Posts: 138 |
Instead of making the files your self is there a way to have perl do that? Like I have someone enter a name and its saved as a .txt file automaticly. How is this done?
------------------ * *** %###*###% ->>>Em8<<<-
|
|
|
|
Joined: Aug 2000
Posts: 3,590
Moderator
|
Moderator
Joined: Aug 2000
Posts: 3,590 |
just write to a file. when writing or appending to a file, the file doesn't have to exist, though the directory does. my $file_name = param('file_name'); # collected from form open(FILEWRITE,">/path/to/file/$file_name.txt")or die "Bad file: $!"; print FILEWRITE 'content'; close(FILEWRITE)or die "Bad file: $!"; ------------------ Da Wannabe Cannuck:: Who is Andy?
|
|
|
|
Joined: May 2000
Posts: 243
Member
|
Member
Joined: May 2000
Posts: 243 |
You forgot some Atom911 open(FILEWRITE," >/path/to/file/$file_name.txt")or die "Bad file: $!"; print FILEWRITE 'content'; close(FILEWRITE)or die "Bad file: $!"; ------------------ Powered by ZCom Bulletin Boards
|
|
|
|
Joined: Aug 2000
Posts: 3,590
Moderator
|
Moderator
Joined: Aug 2000
Posts: 3,590 |
My bad, fixed now I often forget those...always a pain to find out why. ------------------ Da Wannabe Cannuck:: Who is Andy?
|
|
|
|
Joined: Aug 2000
Posts: 335
Member
|
Member
Joined: Aug 2000
Posts: 335 |
If this is for a CGI script, be aware that there are security issues in using user input to form file names.
|
|
|
|
Joined: Aug 2000
Posts: 3,590
Moderator
|
Moderator
Joined: Aug 2000
Posts: 3,590 |
Yes, Dave_L is correct. However, most these dangers can be thwarted by checking the data recieved from the user(as you should be anyway) Here would block all file names with anything but alpha-numeric characters in it: die 'Bad characters in file name.' unless($file_name =~ /^[A-Za-z0-9]$/); ------------------ Da Wannabe Cannuck:: Who is Andy?
|
|
|
|
Joined: Feb 2000
Posts: 4,625
Member
|
Member
Joined: Feb 2000
Posts: 4,625 |
You should check for even more security if your on an NT system, or even a unix system, just incase someone decides to hack you. and ------------------ Hack Developer of the Ultimate Bulletin Board. Due to time limitation, I do not offer support Via. E-mail or AIM. Please post on the forums. Regards, MasterMind
|
|
|
|
Joined: Aug 2000
Posts: 3,590
Moderator
|
Moderator
Joined: Aug 2000
Posts: 3,590 |
MasterMind -- The coding I had listed above would rule out both of the things that you did ------------------ Da Wannabe Cannuck:: Who is Andy?
|
|
|
|
Joined: Feb 2000
Posts: 4,625
Member
|
Member
Joined: Feb 2000
Posts: 4,625 |
Sorry, i must be very tired i didn't even see it. ::sigh:: ------------------ Hack Developer of the Ultimate Bulletin Board. Due to time limitation, I do not offer support Via. E-mail or AIM. Please post on the forums. Regards, MasterMind
|
|
|
|
Joined: Sep 2000
Posts: 138
Member
|
Member
Joined: Sep 2000
Posts: 138 |
Mabey some day I'll be as good as Greg or Andy
------------------ * *** %###*###% ->>>Em8<<<-
|
|
|
|
Joined: Feb 2000
Posts: 4,625
Member
|
Member
Joined: Feb 2000
Posts: 4,625 |
Well, I am not as good as andy, but i'll tell ya, it takes plenty of practice. I need to thank Mark, Andy and cal for their help...and constant putting up with me. ------------------ Hack Developer of the Ultimate Bulletin Board. Due to time limitation, I do not offer support Via. E-mail or AIM. Please post on the forums. Regards, MasterMind
|
|
|
|
Joined: Aug 2000
Posts: 3,590
Moderator
|
Moderator
Joined: Aug 2000
Posts: 3,590 |
Yes, Mark definitely needs to be thanked for many - rather most - of the things I have learned, and the breaking of bad habits and the picking up of new good ones ------------------ Da Wannabe Cannuck:: Who is Andy?
|
|
|
|
Joined: Feb 2000
Posts: 4,625
Member
|
Member
Joined: Feb 2000
Posts: 4,625 |
Here here to that! ------------------ Hack Developer of the Ultimate Bulletin Board. Due to time limitation, I do not offer support Via. E-mail or AIM. Please post on the forums. Regards, MasterMind
|
|
|
|
Joined: Sep 2000
Posts: 755
P.I.T.A. / Programmer
|
P.I.T.A. / Programmer
Joined: Sep 2000
Posts: 755 |
LOL, thx guys To keep up with tradition though, andy...you're about 99% of the way correct with: die 'Bad characters in file name.' unless($file_name =~ /^[A-Za-z0-9]$/); however ya made one BIIIIIG blunder. That regex only allows for a one character filename and a smaller blunder... it doesn't allow for '.', _ and - which are perfectly valid in filenames. I would use full on taint checking: die 'Bad characters in file name.' unless $file_name =~ /^([w.-]+)$/; $file_name = $1; --mark This message has been edited by Mark Badolato on November 26, 2000 at 07:53 PM
"Annnnnnnndd now, opening for Iron Maiden...... WYLD STALLYNS!!!" --Bill S. Preston, Esquire and Ted "Theodore " Logan
|
|
|
|
Joined: Feb 2000
Posts: 4,625
Member
|
Member
Joined: Feb 2000
Posts: 4,625 |
Your welcome mark. ------------------ Hack Developer of the Ultimate Bulletin Board. Due to time limitation, I do not offer support Via. E-mail or AIM. Please post on the forums. Regards, MasterMind
|
|
|
|
Joined: Aug 2000
Posts: 3,590
Moderator
|
Moderator
Joined: Aug 2000
Posts: 3,590 |
hehe, I can't believe I forgot the plus in the regex. ------------------ Da Wannabe Cannuck:: Who is Andy?
|
|
|
Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.
Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
|
|
Posts: 1,157
Joined: July 2001
|
|
Forums63
Topics37,573
Posts293,925
Members13,849
|
Most Online5,166 Sep 15th, 2019
|
|
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
|
|
|
|