I think dasgar has identified the reason you are getting that output from your script.

Not what you want perhaps but it does reveal that

When you are debugging cgi scripts that is a result. You're halfway there. :-)

The script has warnings enabled (the -w on the shebang line) and uses CGI.pm. Also a good thing.

If you're starting out on working with cgi scripts I would suggest putting your script to one side and writing a cut down version and get that working. For instance, if you are able to create a dir under cgi-bin you could create a /cgi-bin/test/test.cgi like the following (i.e. leaving out the email side of things).

test.cgi

#!/usr/bin/perl -w use CGI; $query = new CGI; # let CGI.pm print the content header print $query->header; $cc = $query->param("Ccemail"); $from = $query->param("From"); $subject = $query->param("Subject"); $comment = $query->param("Comment"); $file = $query->param("Attach"); @name = split(/\\/, $file); $name = $name[$#name]; @list = $query->param("list"); $list = join(",", @list); # change the file name to include a path that # the web server can write to # e.g. the path you have in your script open(UPLOAD, ">uploaded_file.txt") or die "Sorry, cannot open $FILE: $!"; my ($data, $chunk); while ($chunk = read($file, $data, 1024)){ print UPLOAD $data; } close(UPLOAD) or die "Cannot close $FILE: $!"; # let CGI.pm help output well formed HTML print $query->start_html; print "subject: $subject<br>"; print "from: $from<br>"; print "cc: $cc<br>"; print "comment: $comment<br>"; print "Attachment: $name<br>"; print $query->end_html;
I've tried to keep the script as close to yours as possible (differences have comments) so that it will be familiar but have taken out the email stuff. Get this bit working first. Set the permissions to executable (0755 ought to do it). A test.txt somewhere you can find it e.g.
one two three
And a test.html in, say, the document root
<html> <head> <title>form test</title> </head> <body> <p>upload file</p> <form name = "test_form" action = "/cgi-bin/test/test.cgi" method = "post" enctype = "multipart/form-data" > from:<br> <input type="text" name="From" ><br> subject:<br><input type="text" name="Subject" ><br> comment:<br><input type="text" name="Comment" ><br> cc:<br> <input type="text" name="Ccemail" ><br> list:<br> <input type="checkbox" name="list" value="Car" > car + <input type="checkbox" name="list" value="Bike"> bik +e<br> attach:<br> <input type="file" name="Attach"><br> <input type="submit" name="Submit" value="Submit"> </form> </body> </html>
The html has a lot of whitespace blown into it which I find useful while developing.

Typing http://your_domain/test.html into your browser should bring up the form. Fill in some dummy data and, if the wind is in the right direction, you will see something like

subject: web broadcast from: a@b.com cc: b@b.com comment: hello Attachment: test.txt
and there should be a file upload_file.txt in cgi-bin/test or wherever you set the path to in the script.

There are a number of good tutorials that will help and it is worth have a look at the docs for CGI.pm (at least, the methods that you are using - there is rather a lot of it).

There are a number of improvements that could be made (secutity, error checking etc) and many other approaches to developing cgi scripts (e.g. setting up your own local web server rather that 'playing' on a production server) but I reckon it's best to build up gradually .

Hope this helps, let us know how you get on and get back to us if you need any more help.

By the way, your introduction to perl was identical to my own. :-)

Good luck!


In reply to Re: Web broadcast e-mail perl script by wfsp
in thread Web broadcast e-mail perl script by goosenoose

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.