Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Nothing is being written into my opt-in.txt file

by bgatto (Initiate)
on Jul 10, 2013 at 20:39 UTC ( #1043558=perlquestion: print w/replies, xml ) Need Help??
bgatto has asked for the wisdom of the Perl Monks concerning the following question:

Hello All,

I'm running an HTML form on a web hostthat looks like this:

<form method=POST action=" +gi"> <b><font face="arial" size=5 color="#ffffff"> Name: <input type="text" name="fullname" size=35><br> &nbsp;eMail: <input type="text" name="email" size=35> </b></font> <p align="center"><input type="submit" name="submit" background="#ffff +00" value="Get It Now" style="font:24pt Arial Black; color:#0000FF;"> +</p> </form>

The code for sendinfo.cgi is:

#!/usr/bin/perl -w use strict; my $sendto = param('email'); my $sendname = param('name'); open (LOG, ">>") || die("Erro +r: " . $!); print LOG $sendname . "," . $sendto . \n; close (LOG);

When I enter my name and email address and click the submit button, I get sent back to the original web site and I get an error. When I go and check the opt-in.txt file, I find nothing in the file. What is going wrong?

Replies are listed 'Best First'.
Re: Nothing is being written into my opt-in.txt file
by Illuminatus (Curate) on Jul 10, 2013 at 20:57 UTC
    1. Your html says 'fullname', but your script is looking for just 'name'
    2. Can you run sendinfo.cgi on the server (modified to take it's params from the cmdline) and have it do what you expect?
    3. If (2) works, make sure the user the webserver is running your script as has permission to do what you want


Re: Nothing is being written into my opt-in.txt file
by thomas895 (Chaplain) on Jul 10, 2013 at 22:55 UTC

    You're all missing the root of the problem:

    open (LOG, ">>") || die("Erro +r: " . $!);

    Something there is wrong, but can you see it?

    "Excuse me for butting in, but I'm interrupt-driven..."

      Excellent, and the second thing that is wrong is failure to check the server logs, where STDERR would have recorded the die message.


Re: Nothing is being written into my opt-in.txt file
by hippo (Monsignor) on Jul 10, 2013 at 21:31 UTC

    Your code doesn't compile:

    $ perl -cw /tmp/ Bareword "n" not allowed while "strict subs" in use at /tmp/ l +ine 9. /tmp/ had compilation errors.

    Haven't we been through this before? Why did you not try to compile the script yourself? Why did you not try looking in the error log?

Re: Nothing is being written into my opt-in.txt file
by poj (Prior) on Jul 10, 2013 at 21:42 UTC
    Use this as your cgi, it will show you what is wrong
    #!/usr/bin/perl -w use strict; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); my $sendto = param('email'); my $sendname = param('fullname'); #my $logfile = ''; my $logfile = '/tmp/opt-in.txt'; my $msg; if ( open LOG, '>>',$logfile ) { print LOG "$sendname,$sendto\n"; close (LOG); $msg = "$sendname $sendto written to $logfile"; } else { $msg = "File open Error: ".$!; } print header(),start_html() ,p($msg) ,a({-href=>'easy.html'},'return') ,end_html();

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1043558]
Approved by davido
[tye]: I don't know if you can just dismount, but I thought so.
[davido]: yeah, umount -f isn't powerful enough.
[tye]: probably something in the init subsystem that does the mounting that you could disable and reboot.
davido needs to close laptop to board flight home from yapc.
[davido]: I'll look into it in a few hours probably.
[davido]: when i do get to that point I think I'll do it in a vm snapshot just in case. :)
[oiskuu]: tye, you were right: loginuid/sessionid are part of task struct if compiled with AUDITSYSCALL. I have some doubts if you should actually depend on that feature.
[Corion]: oiskuu: Depends on what you want to do with that information
[tye]: I'm not depending on that feature. But I could in this environment. I'm using getlogin(). shrug
[Corion]: For benign logging (which user started this DB instance), it's OK

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2017-06-23 20:06 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (555 votes). Check out past polls.