msk_0984 has asked for the wisdom of the Perl Monks concerning the following question:
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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Writing to the File
by shmem (Chancellor) on Jun 28, 2006 at 13:43 UTC | |
|
Re: Writing to the File
by blue_cowdawg (Monsignor) on Jun 28, 2006 at 13:59 UTC | |
by msk_0984 (Friar) on Jun 29, 2006 at 04:35 UTC | |
|
Re: Writing to the File
by jesuashok (Curate) on Jun 28, 2006 at 13:05 UTC | |
by msk_0984 (Friar) on Jun 28, 2006 at 13:08 UTC | |
by jesuashok (Curate) on Jun 28, 2006 at 13:17 UTC | |
|
Re: Writing to the File
by Moron (Curate) on Jun 28, 2006 at 15:55 UTC |