Hi Folks,
I have a CGI that writes to a flat file and does some other functionality. I have built an "admin" front-end to edit the records of the flat file (by pre-populating the form the user entered, allowing the admin to make edits/changes). That works just fine, but now I want to have the ability to DELETE a record/line in the flat file -- and I think it is because it's owned by httpd. I would make sense if I'm having permission issues as nothing happens when I try to delete but the code checks clean. Here's the relevant snippets.
$logfile = "tempfile.tmp";
$logfileOrig = "logfile.log";
chmod 777, $logfile; #the 777 is for testing,
chmod 777, $logfileOrig; #it won't be WIDE open
sub makeff {
#copy existing logfile to tempfile, while skipping record I want d
+eleted
open (LOGFILE, ">$logfile") or die("Can't Open Log File at $logfil
+e");
open (ORIG, "<$logfileOrig") or die("Can't Open Log File at $logfi
+leOrig");
while (my $origLine = <ORIG>) {
$currentline ++;
print LOGFILE $origLine unless $currentline == $linenumber;
}
close (ORIG);
close (LOGFILE);
rename $logfile, $logfileOrig if $linenumber;
}
$linenumber is the value passed to the delete CGI
print OUTFILE "<FORM NAME=\"FORM\" METHOD=\"POST\" ACTION=\"del
+ete.cgi\">";
print OUTFILE "<input type='hidden' name='linenumber' value='$l
+inenumber'>";
print OUTFILE "<INPUT TYPE=SUBMIT VALUE=\"DELETE THIS RECORD\">
+</FORM><br>\n";
Note there is no administration of this server and I can't su into it either. Please let me know if you see where I'm off somewhere. Thanks Folks!
lakeTrout
UPDATE: I added essentially the entire script to my
scratch pad (I removed some extraneous stuff, like the 40 something for querys for better readability). I know it's crude, but it WORKS, except for the delete part I'm trying to build.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.