I am trying to send a mail and also trying to append the data to a File but i am getting a problem when i saying
Permission is Denied
i have changed the guestbook.txt permission to 777 and also tried but i am getting this prob i hav also tried to change teh user and th e group but that did not work. plz help me out .
#!/usr/bin/perl -wT use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use strict; print header; print start_html("Results"); # first print the mail message... $ENV{PATH} = "/usr/sbin"; open (MAIL, "|/usr/sbin/sendmail -oi -t -odq") or &dienice("Can't fork for sendmail: $!\n"); print MAIL "To: recipient\@cgi101.com\n"; print MAIL "From: nobody\@cgi101.com\n"; print MAIL "Subject: Form Data\n\n"; foreach my $p (param()) { print MAIL "$p = ", param($p), "\n"; } close(MAIL); # now write (append) to the file open(OUT, ">>guestbook.txt") or &dienice("Couldn't open output file: $ +!"); foreach my $p (param()) { print OUT param($p), "|"; } print OUT "\n"; close(OUT); print <<EndHTML; <h2>Thank You</h2> <p>Thank you for writing!</p> <p>Return to our <a href="index.html">home page</a>.</p> EndHTML print end_html; sub dienice { my($errmsg) = @_; print "<h2>Error</h2>\n"; print "<p>$errmsg</p>\n"; print end_html; exit; }
In reply to Writing to the File by msk_0984
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |