CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Perl beginner - I need help please

 



JennyW
journeyman

May 16, 2001, 10:19 AM

Post #1 of 123 (10275 views)
Perl beginner - I need help please Can't Post

Hi,
I’m a VERY new beginner.

I have Perl and Apache on my computer.
I want to start testing CGI scripts for my website, but I don’t know where to go from here.

In order to get Apache to run a CGI script I was told to add ExecCGI to the “Options” line in the httpd.conf file.

I added it, then I made a script called, simple.cgi. I tested the script in IE at the http://127.0.0.1/cgi-bin/simple.cgi address, but I got the “Connection Refused” window.

Does anyone know what I’m doing wrong?

Thanks for your time,
Jenny




Kanji
User / Moderator

May 16, 2001, 4:02 PM

Post #2 of 123 (10266 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

"Connection refused" sounds like you either have a firewall/web proxy in place, or your copy of Apache isn't running.



JennyW
journeyman

May 16, 2001, 4:46 PM

Post #3 of 123 (10260 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Kanji,
Thanks for responding.
My Apache is running and I DON'T have a Firewall. What else could it be?

Maybe my CGI script?

Here's my script...

#!c:/perl/bin/bin
print "Content-type: text/html\n\n";
print "Not Hello, again!\n";

It's in the CGI-bin (within Apache).

Any help is appreciated.

Thanks,
Jenny



Kanji
User / Moderator

May 16, 2001, 4:55 PM

Post #4 of 123 (10258 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

I don't think it's your script.

Have you looked in your Apache logs to see if you really are connecting?




JennyW
journeyman

May 16, 2001, 4:59 PM

Post #5 of 123 (10257 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hiee!
Well, the Apache window is open and displays...

Apache/1.3.19 <Win32> running...

How can I check the Apache logs to see if I'm connected? What are Apache logs?

Thanks,
Jenny



Kanji
User / Moderator

May 16, 2001, 6:16 PM

Post #6 of 123 (10254 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Apache logs keep track of which pages have been served, when, and to whom.

Usually, they are located inside the logs/ subdirectory found wherever you installed Apache and called access.log.



JennyW
journeyman

May 16, 2001, 6:35 PM

Post #7 of 123 (10252 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Kanji.

Here's what my logs display in Notepad...

access.log


127.0.0.1 - - [13/May/2001:18:29:57 -0400] "GET / HTTP/1.1" 200 1354
127.0.0.1 - - [13/May/2001:18:29:58 -0400] "GET /apache_pb.gif HTTP/1.1" 200 2326
127.0.0.1 - - [13/May/2001:18:31:31 -0400] "GET /manual/ HTTP/1.1" 200 5740
127.0.0.1 - - [13/May/2001:18:31:31 -0400] "GET /manual/images/apache_header.gif HTTP/1.1" 200 4084
127.0.0.1 - - [13/May/2001:18:31:31 -0400] "GET /manual/images/pixel.gif HTTP/1.1" 200 61
127.0.0.1 - - [13/May/2001:18:34:03 -0400] "GET / HTTP/1.1" 200 1354
127.0.0.1 - - [13/May/2001:18:52:14 -0400] "GET / HTTP/1.1" 200 1354
127.0.0.1 - - [13/May/2001:21:59:00 -0400] "GET / HTTP/1.1" 200 1354
127.0.0.1 - - [13/May/2001:21:59:00 -0400] "GET /apache_pb.gif HTTP/1.1" 304 -
127.0.0.1 - - [14/May/2001:20:44:28 -0400] "GET / HTTP/1.1" 200 1354
127.0.0.1 - - [14/May/2001:20:44:28 -0400] "GET /apache_pb.gif HTTP/1.1" 304 -
127.0.0.1 - - [14/May/2001:20:45:20 -0400] "GET /cgi-bin/ScriptName HTTP/1.1" 404 312
127.0.0.1 - - [14/May/2001:20:45:39 -0400] "GET /cgi-bin/printenv.pl HTTP/1.1" 500 634
127.0.0.1 - - [14/May/2001:20:46:37 -0400] "GET /cgi-bin/first HTTP/1.1" 404 307
127.0.0.1 - - [15/May/2001:18:20:05 -0400] "GET /cgi-bin/simple.cgi HTTP/1.1" 404 312
127.0.0.1 - - [15/May/2001:18:42:45 -0400] "GET / HTTP/1.1" 200 1354
127.0.0.1 - - [15/May/2001:18:42:46 -0400] "GET /apache_pb.gif HTTP/1.1" 304 -
127.0.0.1 - - [15/May/2001:18:43:29 -0400] "GET /cgi-bin/simple.cgi HTTP/1.1" 500 634
127.0.0.1 - - [15/May/2001:22:04:15 -0400] "GET /cgi-bin/simple.cgi HTTP/1.1" 500 634
127.0.0.1 - - [16/May/2001:20:27:53 -0400] "GET / HTTP/1.1" 200 1354
127.0.0.1 - - [16/May/2001:20:27:53 -0400] "GET /apache_pb.gif HTTP/1.1" 304 -
127.0.0.1 - - [16/May/2001:20:30:06 -0400] "GET / HTTP/1.1" 200 1354
127.0.0.1 - - [16/May/2001:20:30:34 -0400] "GET /cgi-bin/simple.cgi HTTP/1.0" 500 622


error.log

Apache server shutdown initiated...
Apache server shutdown initiated...
[Mon May 14 20:45:20 2001] [error] [client 127.0.0.1] (2)No such file or directory: script not found or unable to stat: c:/program files/apache group/apache/cgi-bin/scriptname
[Mon May 14 20:45:39 2001] [error] [client 127.0.0.1] couldn't spawn child process: c:/program files/apache group/apache/cgi-bin/printenv.pl
[Mon May 14 20:46:37 2001] [error] [client 127.0.0.1] (2)No such file or directory: script not found or unable to stat: c:/program files/apache group/apache/cgi-bin/first
[Tue May 15 18:20:05 2001] [error] [client 127.0.0.1] (2)No such file or directory: script not found or unable to stat: c:/program files/apache group/apache/cgi-bin/simple.cgi
[Tue May 15 18:43:29 2001] [error] [client 127.0.0.1] couldn't spawn child process: c:/program files/apache group/apache/cgi-bin/simple.cgi
[Tue May 15 22:04:15 2001] [error] [client 127.0.0.1] couldn't spawn child process: c:/program files/apache group/apache/cgi-bin/simple.cgi
[Wed May 16 20:30:34 2001] [error] [client 127.0.0.1] couldn't spawn child process: c:/program files/apache group/apache/cgi-bin/simple.cgi


Does this tell you anything?

Could the problem lie within my Perl installation? How can I check if perl is OK?

Thanks,
Jenny





Cure
User

May 16, 2001, 7:48 PM

Post #8 of 123 (10249 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Options Indexes FollowSymLinks MultiViews
Options All ExecCGI


Cure



mhx
Enthusiast / Moderator

May 16, 2001, 11:08 PM

Post #9 of 123 (10244 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny!

Just a guess, but perhaps it helps. I think I've encountered the same error when I was first running Perl/Apache under Windows. My problem was the shebang line in the cgi-script. Apache needs to know the exact location of your perl interpreter. For me, it was

C:\Programme\perl\bin\perl.exe

so I had to put

#!C:\Programme\perl\bin\perl.exe

as the first line of my cgi-script. Anything else doesn't work. While the script may run perfectly if it is started directly, it will not work when Apache is trying to start it.
(This can be quite annoying if you develop a script using a Windows installation and upload the script on a UNIX server, because it just won't work unless you change the shebang-line...)

Hope this helps.

-- Marcus



JennyW
journeyman

May 17, 2001, 6:23 AM

Post #10 of 123 (10235 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hiee Marcus!

I heard you have to take out the .exe extension on perl.exe?

You wrote…
Anything else doesn't work. While the script may run perfectly if it is started directly, it will not work when Apache is trying to start it.

What do you mean here?

You also wrote…
(This can be quite annoying if you develop a script using a Windows installation and upload the script on a UNIX server, because it just won't work unless you change the shebang-line...)

How would I change the shebang line?

Also,

You wrote that my shebang line should look like this…

#!C:\Programme\perl\bin\perl.exe

My path is the same. However, I have a few questions.

1. Instead of “Programme” I have Program Files. How are spaces treated (the space between Program Files)?
2. Does the C: and Program Files have to be capitalized?

Thanks so much,
Jenny




mhx
Enthusiast / Moderator

May 17, 2001, 12:50 PM

Post #11 of 123 (10228 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny!

> I heard you have to take out the .exe extension on perl.exe?

It doesn't matter if you take it out or leave it, at least on my machine.

>You wrote…
>Anything else doesn't work. While the script may run perfectly if it is started directly, it will not work when Apache is trying to start it.
>What do you mean here?

You can start (most) cgi-scripts from with the Perl interpreter directly from the command line. You don't get the HTML content displayed in your browser, but only printed in your command window. Under Windows, the shebang line is not of importance, except for the options you pass to the interpreter.
Under Unix, it is used to determine the location of your interpreter. Apache also uses the line to determine the location of the interpreter under Windows.

> How would I change the shebang line?

I'm not quite sure what you want to know here ;-)
You can just edit the line (?). Under Unix, the shebang line normally looks like


Code
#!/usr/local/bin/perl

Since I'm also testing my scripts under Windows, but my server is running Unix, I've written an upload script that not only uploads all new or modified files automatically, but also changes the shebang line of all cgi-scripts temporarily when uploading.
I hope the answer you expected is somewhere in between...

> 1. Instead of “Programme” I have Program Files. How are spaces treated (the space between Program Files)?

That seems to be a problem. (I guess the german version of Windows has a slight advantage here...) I've tried to get my script running with spaces in the path, but it didn't work. I'd recommend that you install Perl in another folder, say 'c:\bin\', as I do when I'm working with the english version.

> 2. Does the C: and Program Files have to be capitalized?

No, they don't. Unlike Unix, Windows isn't case sensitive here.

I hope all this makes the situation a bit clearer.

Greetings,
Marcus



JennyW
journeyman

May 18, 2001, 4:12 PM

Post #12 of 123 (10210 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Success!

Here’s the script that worked for me...

#!c:/perl/bin/bin/perl
print "Content-type: text/html\n\n";
print "Not Hello, again!\n";

My main and most recent problem was my incorrect path in my shebang line, but it’s ok now. Thanks.
Does my shebang line need to be like that for every script I have? Will my shebang line be different if I'm posting a .cgi script to a webhost’s server?

I have a few more important questions…

The script above was named simple.cgi

When I tested my script I was successful using the following url in both Netscape and IE…
http://localhost/cgi-bin/simple.cgi

However, my test only worked for Netscape under this url…
http://127.0.0.1/cgi-bin/simple.cgi

When I entered the above url in IE I received this message...

Connection refused
Description: Connection refused

Is this a problem? Why did this happen only for the http://127.0.0.1/cgi-bin/simple.cgi address on Internet Explorer?

What the difference between the localhost and the 127.0.0.1 extension?

And finally…

What do I open when I want to test scripts directly in perl?
Do I open (double click) perl.exe ?

What would be the point of testing scripts directly in perl?

Thanks so much for taking the time,
Jenny





mhx
Enthusiast / Moderator

May 18, 2001, 11:26 PM

Post #13 of 123 (10198 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny!

> Does my shebang line need to be like that for every script I have?

On your machine, as long as the Perl interpreter does not move, yes. Except I would generally recommend to append a '-w' to the shebang line to make Perl issue some warnings. This generally leads to better Perl code and fewer / easier to find errors.

> Will my shebang line be different if I'm posting a .cgi script to a webhost’s server?

I think so. I've not seen a webserver yet having perl installed in 'c:/perl/bin/bin/perl'. Since most webservers I know about run Unix or Linux, your shebang line should most likely be


Code
#!/usr/local/bin/perl -w

But most webspace providers with cgi support list on their page where perl and sendmail are installed.

> When I tested my script I was successful using the following url in both Netscape and IE
> http://localhost/cgi-bin/simple.cgi
> However, my test only worked for Netscape under this url
> http://127.0.0.1/cgi-bin/simple.cgi
> When I entered the above url in IE I received this message...
> Connection refused
> Description: Connection refused
> Is this a problem?

I don't think so. At least I don't think it's your problem. Perhaps it's your version of IE, although I really can't imagine why it would work the one way, but not the other. I've tried to reproduce this on my machine, but my IE (Version 5.00.2919.6307IC) worked with both URLs.

> Why did this happen only for the http://127.0.0.1/cgi-bin/simple.cgi address on Internet Explorer?

I can't tell you, really. Perhaps you can get some more information from Apache's server logs.

> What the difference between the localhost and the 127.0.0.1 extension?

There should be none. Here's what the Apache config file says:

# 127.0.0.1 is the TCP/IP local loop-back address, often named localhost. Your
# machine always knows itself by this address. If you use Apache strictly for
# local testing and development, you may use 127.0.0.1 as the server name.

BTW, there was another interesting thing in the config file:

# Apache parses all CGI scripts for the shebang line by default.
# This comment line, the first line of the script, consists of the symbols
# pound (#) and exclamation (!) followed by the path of the program that
# can execute this specific script. For a perl script, with perl.exe in
# the C:\Program Files\Perl directory, the shebang line should be:

#!c:/program files/perl/perl

# Note you _must_not_ indent the actual shebang line, and it must be the
# first line of the file. Of course, CGI processing must be enabled by
# the appropriate ScriptAlias or Options ExecCGI directives for the files
# or directory in question.

I guess, reading the complete config file could be quite useful for me... Smile

> And finally
> What do I open when I want to test scripts directly in perl?
> Do I open (double click) perl.exe ?
No, you open a command prompt, change to the directory your scripts are in, and run the script with

Code
perl simple.cgi

> What would be the point of testing scripts directly in perl?
Well, um, I can't see a point right now. When I started writing cgi scripts, I had quite a lot of experience writing Perl scripts.
So I was more familiar with the command line execution of my scripts, and I've been struggling with Apache just as you did Crazy
I only ran cgi scripts directly to trap errors. But there's a better way to do this. Just start every script you write with


Code
#!c:\programme\perl\bin\perl.exe -w 
use CGI::Carp qw(fatalsToBrowser);
use CGI qw/:standard/;
use strict;

The CGI::Carp qw(fatalsToBrowser) will make all perl errors appear in your browser window.
The CGI qw/:standard/ will be a great support when you want to generate HTML and parse CGI forms. One should really use this!
The use strict is because I'm a Perl writer. Perl (and CGI) scripts tend to become more readable and error free when using this.

If there's anything else you'd like to know, or you would want in more detail, just ask.

-- Marcus




JennyW
journeyman

May 19, 2001, 10:59 AM

Post #14 of 123 (10189 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi,
Wow, thanks for the great response!

1. You wrote...
#!c:\programme\perl\bin\perl.exe -w
use CGI::Carp qw(fatalsToBrowser);
use CGI qw/:standard/;
use strict;

Should the above be my FIRST four lines in all of my .cgi scripts?

2. I got to the command line, but I could things going.
I would type…

cd\program files

…but it wouldn’t recognize my request. It would say…Too many parameters – files

Is it because…

Program Files

…has a space in between it?

Do you know how I can get through this is DOS?

3. You quoted the httpd.conf with the following…

# Apache parses all CGI scripts for the shebang line by default.

What does the above mean?

Thanks so much for taking the time,
Jenny




mhx
Enthusiast / Moderator

May 19, 2001, 1:32 PM

Post #15 of 123 (10187 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

> Should the above be my FIRST four lines in all of my .cgi scripts?

Well, more or less yes. I strongly recommend 'use strict', because it forces a clean programming style. The two CGI modules are very useful for CGI programming. IMO far too less people are using it and mess around i.e. with parsing for CGI parameters. The shebang line is of course mandatory and must be the first. The others should appear somewhere on top of your script. If you include any other modules, put them before, somewhere in between, whatever you like. It's not of importance, as long as all this appears on top of your code.

> Is it because Program Files has a space in between it?
> Do you know how I can get through this is DOS?

Yes, it is. You can change to this folder by typing

Code
cd "\program files"

Just quote any directory/file names with spaces in between when using the DOS prompt.

> 3. You quoted the httpd.conf with the following…
> Apache parses all CGI scripts for the shebang line by default.
> What does the above mean?

I just quoted this paragraph because it shows that the path in the shebang line may contain spaces. I don't know why this failed to work on my machine. The above just means that Apache looks at the shebang line to find out where the Perl interpreter is located.

-- Marcus



JennyW
journeyman

May 20, 2001, 2:20 PM

Post #16 of 123 (10172 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi mhx,
You wrote…

Yes, it is. You can change to this folder by typing
cd "\program files"

That worked great! Thanks!

Thanks to your help I’m beginning to test .cgi scripts! However, I need your assistance, because I’m having some trouble.

1. Here’s my html Form…

<HTML>
<HEAD><TITLE>Most Basic CGI Input Page</TITLE></HEAD>
<BODY>
<FORM ACTION="emailtest.cgi" METHOD="POST">
<P>email, please:
<INPUT TYPE="TEXT" WIDTH="25" NAME="Email_Address">
</P></FORM></BODY></HTML>

2. I tested my <html> Form with the following .cgi code. My results were strange.
(The .cgi script below is suppose to accept any email address and display it on a new page).

By the way, I haven’t used your code yet…

#!c:\programme\perl\bin\perl.exe -w
use CGI::Carp qw(fatalsToBrowser);
use CGI qw/:standard/;
use strict;


I’m definitely going to use this code in the NEAR future. I just wanna get a handle on the basics first. Here’s the .cgi code I used…


#!/usr/local/bin/perl
#
%FORM = &cgidecode();
$email = $FORM{Email_Address};
print "Content-type: text/html\n\n";
print "<HTML><HEAD><TITLE>Catching an email</TITLE></HEAD>\n";
print "<BODY><P>Address is: $email.</P></BODY></HTML>";

sub cgidecode
{
local(%vars, $val, $key, $last, $buffer, $pair, @pairs);
# Checking the form method (GET or POST) used
# in the HTML code. POST method sends data to
# standard input, but GET adds it to the URL
# and stores it in QUERY_STRING.
if ($ENV{'REQUEST_METHOD'} eq "POST")
{ read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); }
else
{ $buffer = $ENV{'QUERY_STRING'}; }

# Splitting up the data fields and store in array @pairs,
# they are seperated with &
@pairs = split(/&/, $buffer);

# Splitting the variable names and the values and storing
# them in the assoc. array %vars
foreach $pair (@pairs)
{
($key, $val) = split(/=/, $pair);
$val =~ s/\+/ /g;
$val =~ s/%(..)/pack("C",hex($1))/eg;
if ($key eq $last) {$vars{$key} .= " ".$val; }
else { $vars{$key} = $val; }
$last = $key;
}
return(%vars);
}



After I entered an email address I was brought to a new screen, which displayed the following…



#!c:/perl/bin/bin/perl # %FORM = &cgidecode(); $email = $FORM{Email_Address}; print "Content-type: text/html\n\n"; print "\n"; print "
Address is: $email.
"; sub cgidecode { local(%vars, $val, $key, $last, $buffer, $pair, @pairs); # Checking the form method (GET or POST) used # in the HTML code. POST method sends data to # standard input, but GET adds it to the URL # and stores it in QUERY_STRING. if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } else { $buffer = $ENV{'QUERY_STRING'}; } # Splitting up the data fields and store in array @pairs, # they are seperated with & @pairs = split(/&/, $buffer); # Splitting the variable names and the values and storing # them in the assoc. array %vars foreach $pair (@pairs) { ($key, $val) = split(/=/, $pair); $val =~ s/\+/ /g; $val =~ s/%(..)/pack("C",hex($1))/eg; if ($key eq $last) {$vars{$key} .= " ".$val; } else { $vars{$key} = $val; } $last = $key; } return(%vars); }

Do you know what could have happened here?

Thanks,
Jenny




mhx
Enthusiast / Moderator

May 20, 2001, 11:55 PM

Post #17 of 123 (10168 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

I've tested your html/script on my machine. After applying two minor changes, they worked absolutely fine. These changes were:
1. The shebang line wasn't ok for my system
2. I had to change "emailtest.cgi" to "cgi-bin/emailtest.cgi"
I think both changes don't have anything to do with your problem, but only with my configuration.
Now, let's move on to analyze your problem. Did you ever get a cgi-script running with your current configuration? It seems that Apache is finding your cgi script, but doesn't know how to interpret it, so it just sends the script to the browser as plain ascii data. If you've been running scripts with this configuration, I really don't know why it doesn't work. If this is the first script you're trying to run, I guess it could be that your Apache httpd.conf is not properly set up.
You should take a look at this file and see if the "ExecCGI" option is enabled and if there's a line

Code
AddHandler cgi-script .cgi .pl

I'm sorry I can't give you more precise information about this.
Anyway, to convince you of using the CGI modules, I have rewritten the code you posted in a way that uses my first four lines and is - so I guess - more readable and understandable for the beginner. Although it doesn't use a single HTML tag, it contains both, the HTML and the CGI, in one file that is significantly shorter than the two original files. To make a transition easier, this script produces exactly the same output as yours, except it adds a 'Submit' button to the form.

Code
#!c:\programme\perl\bin\perl.exe -w 
use CGI::Carp qw(fatalsToBrowser);
use CGI qw/:standard/;
use strict;

print header;

unless( param() ) # no parameters? => display form!
{
print start_html(-title => "Most Basic CGI Input Page"), start_form;
print "email, please: ", textfield(-size => 25, -name => 'Email_Address');
print submit('Submit'), end_form;
}
else # we have parameters => display results!
{
print start_html(-title => "Catching an email");
print p("Address is: ", param('Email_Address'));
}

print end_html;

I think the script is self-explanatory. If it should not be, ask and I'll explain.

-- Marcus



JennyW
journeyman

May 21, 2001, 12:14 PM

Post #18 of 123 (10161 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi mhx and others!

Ok, to start, yes, I have got the simple script…”Hello World” to work on my machine.

Here’s the code I used for that script…

Code
#!c:/perl/bin/bin/perl 
print "Content-type: text/html\n\n";
print "Hello World!\n";

I just can’t seem to get this script working.

You wrote…

>If this is the first script you're trying to run, I guess it could be that your Apache >httpd.conf is not properly set up.
>You should take a look at this file and see if the "ExecCGI" option is enabled and if >there's a line
>

Code
>AddHandler cgi-script .cgi .pl

My httpd.conf file does have the ExecCGI file enabled, but I’ve never done anything with the…

Code
AddHandler cgi-script .cgi .pl

What is AddHandler? Is it necessary?

I heard when using windows all of my .cgi files should have the .pl extension instead. Is that correct?

Also, I tried running the script you posted, but I couldn’t.
I named the file…


Code
 mhx_email_test.cgi

…and I tried to open it in a browser (IE), but was unsuccessful. Nothing happens when I open it.

Thanks,
Jenny





JennyW
journeyman

May 21, 2001, 12:54 PM

Post #19 of 123 (10161 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi mhx,

Ok, I’m starting to think a little late today.
I got your script working.

I typed the following in the url bar…

Code
http://localhost/cgi-bin/mhx_email_test.cgi

…and your script appeared as did my tested results.

If you can, read the post I wrote before this one. It has a few more questions in it. However, if you don’t have the time then don’t worry about it, you’ve been so good to me.

Thanks,
Jenny




mhx
Enthusiast / Moderator

May 21, 2001, 1:07 PM

Post #20 of 123 (10159 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

> What is AddHandler? Is it necessary?

The AddHandler line tells Apache that files with .pl or .cgi extension are CGI-scripts. So Apache will add a handler for cgi-scripts. Well, I'm not sure if it's really neccessary. If I'd be running my own server, I'd probably know more about Apache ;-)

> I heard when using windows all of my .cgi files should have the .pl extension instead. Is that correct?

Well, I guess not. I think what you heard comes from that fact that the extension .pl is usually associated with Perl under Windows, while .cgi is not. You can configure the Windows version of Apache to use file association from the Windows registry. If you don't have the AddHandler line, then perhaps it will work only with the .pl extension. But, as I said before, I'm no Apache expert. I've installed it, configured it, and now only use it for offline testing of my less than 5 cgi-scripts... I think I'm more into Perl that into web programming. But I try to help where I can.

-- Marcus



JennyW
journeyman

May 22, 2001, 10:07 AM

Post #21 of 123 (10140 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus :)

I adjusted the Addhandler field in my httpd.conf file. So that’s all set up! Thanks for the info.

As always I have another problem. I’m trying to test a .cgi script, but I’m having a ‘lil trouble.

The .cgi script I’m trying to test allows website visitors to easily email me from an <html> Form.

I highlighted the segments I think I’m making errors on.
Below is only part of the script. To see the whole script go to this link…
http://members.home.net/pie3.14/AlphaMail.txt

In Reply To
#!c:\perl\bin\bin\perl.exe -w
use CGI::Carp qw(fatalsToBrowser);
use CGI qw/:standard/;
use strict;

# URL to go to if there is a problem with form input
$ErrorPage = "a_fail.html";

# URL to go to when form has been successfully submitted
$ThankPage = "a_thanks.html";

# URL to go to if a 'foreign' referer calls the script
$EvilReferer = "http://www.cnn.com";;

# E-mail address to send intake form to (your address)
# If not using PERL 5, escape the @ thus: \@ instead of @
$YourEmail = 'themustache@hotmail.com';

# Script works only on your server(s) - ('URL1','URL2')
@referers = ('www.yoursite.com','yoursite.com');

# Location of mail program - check your doc or ask admin
$MailProgram = '/usr/lib/sendmail';

# Subject of the e-mail autoreply to the submitter
$Subject = "Thanks for Your Message!";

# Header line in the auto-reply message
$Header = "GOOBERS UNLIMITED";

# Brief tail message for body of e-mail autoreply
$TailMessage = "If your message requires a reply, we'll get back to you soon.";

# Your signature lines the end of the autoreply e-mail
$Signature1 = "John Q. Public";
$Signature2 = "www.YourSite.com";;

I’m unsure what to enter in the highlighted segments? Is this where I’m making errors?

Thanks,
Jenny



mhx
Enthusiast / Moderator

May 22, 2001, 11:07 AM

Post #22 of 123 (10139 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

First, kill the 'use strict' line. This script wasn't supposed to run in 'strict' mode, because it doesn't declare its variables. (It's not yours originally, is it?)
Most of the highlighted segments are uncritical.
$ErrorPage and $ThankPage should both point to existing HTML files.
@referers should contain the name of the server where the script resides. If you're testing locally, it's 'localhost'.
$MailProgram is the most important thing. If you have sendmail installed (which I believe you don't have, I don't even know if there's a windows port of it), you must enter the path to sendmail here. For testing, you have to upload the script to your webspace provider and enter the path where he has installed sendmail. First of all, you should check if your provider supports sending mail.

I hope this makes it a bit clearer.

-- Marcus



JennyW
journeyman

May 22, 2001, 11:44 AM

Post #23 of 123 (10137 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus,
To start, no this script isn’t mine. I got it off a link from this site.

In Reply To
You wrote…
@referers should contain the name of the server where the script resides. If you're testing locally, it's 'localhost'.

So the segment that looks like this…

# Script works only on your server(s) - ('URL1','URL2')
@referers = ('www.yoursite.com','yoursite.com');

Should look like this?

# Script works only on your server(s) - ('URL1','URL2')
@referers = ('http://localhost','yoursite.com');

It’s just plain ‘ol localhost? Not localhost/cgi-bin/fileman.cgi ?

Why does the above say URL1, URL2?


In Reply To
You wrote…

$MailProgram is the most important thing. If you have sendmail installed (which I believe you don't have, I don't even know if there's a windows port of it), you must enter the path to sendmail here. For testing, you have to upload the script to your webspace provider and enter the path where he has installed sendmail. First of all, you should check if your provider supports sending mail.


I don’t have a host right now, that’s why I’m testing on Apache.
What is sendmail?
Do ALL emails sent from a Form require Sendmail?

I’m gonna have to try to see if I can find that Sendmail somewhere.

Thanks,
Jenny



mhx
Enthusiast / Moderator

May 22, 2001, 1:21 PM

Post #24 of 123 (10135 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

> # Script works only on your server(s) - ('URL1','URL2')
> @referers = ('http://localhost','yoursite.com');
> It’s just plain ‘ol localhost? Not localhost/cgi-bin/fileman.cgi ?

I think it's just 'localhost'. But, anyway, I'm not sure if you will be able to get the script to work under Windows.

> I don’t have a host right now, that’s why I’m testing on Apache.

You should try to get a webspace provider. If you don't know any, try www.netfirms.com. Their service is free, and they offer CGI and sendmail support. That's how I'm testing scripts that use sendmail.

> What is sendmail?

sendmail is a (Unix) program to send e-mail. You just feed in a mail in ascii format and sendmail does all the rest.

> Do ALL emails sent from a Form require Sendmail?

Yes. Not actually sendmail, but at least another program that is able to send e-mail and can be controlled from perl.
Here's a script I've assembled to test email sending at www.netfirms.com:

Code
#!/usr/bin/perl -w 
use CGI::Carp qw(fatalsToBrowser);
use CGI qw/:standard/;
use strict;

print header, start_html(-title => "Send me mail!");

if( param() && param('matter') ) {
my $mymail = 'Marcus Holland <marcus@holland.de>';
my $sender = param('sender') || 'anonymous@nowhere.com';
my $subject = param('subject') || 'no subject';

open SENDMAIL, "| /usr/lib/sendmail -oi -t" or die "cannot open sendmail: $!";
print SENDMAIL "From: $sender\nTo: $mymail\nSubject: $subject\n".param('matter');
close SENDMAIL or die "cannot close sendmail: $!";

print p('Your mail has been sent!');
}
else {
print start_form,
table(Tr([
td([ b('From:'), textfield( -name => 'sender', -size => 35, -maxlength => 100 ) ]),
td([ b('Subject:'), textfield( -name => 'subject', -size => 35, -maxlength => 100 ) ]),
])),
table(Tr([
td([ textarea( -name => 'matter', -rows => 12, -columns => 40 ) ]),
td([ submit('Send!') ]),
])),
end_form;
}

print end_html;

It should work for most providers and doesn't have so much parameters to be configured. But it's only a test.

-- Marcus




JennyW
journeyman

May 23, 2001, 8:45 AM

Post #25 of 123 (10123 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus!

Thanks for the referral to http://www.netfirms.com ! This is exactly what I needed all along! You’ve made me very happy!

Now, I have a few questions for you.

1.What’s the difference between Formmail and Sendmail?
2.Can I use any email through Sendmail? E.g. hotmail accounts?


In Reply To
Netfirms.com wrote…
Set the file permissions on the cgi script file and directories to be 'chmod 755'.

3.What does this mean? How can I do this?
I read it has something to do with FTP. I use WSFTP.

Most importantly…

A few days ago you supplied me with that email catching .cgi code. I noticed that the html and the .cgi where combined into one document.
See code…

http://members.home.net/pie3.14/email_catching.txt

I think this is a problem for me. I think I need to have a static html page with a Form that calls my .cgi program to send the email.

The reason for this is I want to place my Form on a specific location on my html page.
For example, I want to place my Form where the black box is located on the following page…

http://members.home.net/pie3.14/0013_tek_tips_cgi_help.html

4.Would it be better to have my Form call my .cgi program to send me the mail?

Thanks again and again!
Jenny



mhx
Enthusiast / Moderator

May 23, 2001, 6:12 PM

Post #26 of 123 (8318 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

> 1.What’s the difference between Formmail and Sendmail?

The difference is (at least for me): I know sendmail, but I don't know formmail ;-) Sorry I can't help you with that.

> 2.Can I use any email through Sendmail? E.g. hotmail accounts?

I don't know exactly what you mean here, but if your point is whether you can send mail to any accounts, the answer is yes.

> Set the file permissions on the cgi script file and directories to be 'chmod 755'.
> 3.What does this mean? How can I do this?
> I read it has something to do with FTP. I use WSFTP.

It's not so much about FTP. Apache at netfirms is configured to accept only files with certain permissions. But you can use your FTP client to set the permissions using the chmod command.
I've been working with WSFTP some years ago until I discovered LeechFTP, which I find much easier to use. If you like to try it, it's free.
Using LeechFTP, you can send a chmod command by right clicking on a remote file and selecting 'Set Attributes...'. 755 is Read and Execute for everyone and Write only for Owner.

> 4.Would it be better to have my Form call my .cgi program to send me the mail?

Yes, I think so. You should place the form in your HTML file and use the cgi script only for sending the mail.
CGI-only sites are only useful if most of the content is dynamic. If there's lots of static stuff, you should separate HTML and CGI.
I've written a CGI-only website. It's a small search engine for my DVD collection. And it's in german ;-) There's not a single HTML file, only two CGI scripts managing the whole site. (Plus an admin & statistics script, but these are only for me.)

Bye,
Marcus



JennyW
journeyman

May 24, 2001, 5:56 AM

Post #27 of 123 (8308 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus,

I used to use Leetch, but then I moved to WSFTP. I had a lot of login problems with Leetch. Basically, it wouldn’t let me login to certain ftp clients once in a while.

I have a few questions for you…
1. I uploaded my a Form to…

http://jennyw.netfirms.com/

I used .cgi code (link) below…

http://members.home.net/pie3.14/AlphaMail.txt

I ONLY adjusted the settable variables, the shebang line and the line under it.
Line under shebang line

Code
use CGI::Carp qw(fatalsToBrowser);

I can’t get my Form to work. I always receive this error…

In Reply To
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, Your Webmaster and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.

I know I have the location of perl and sendmail correct. I’ve also set my .cgi file permissions to 755.

2. Am I suppose to do anything with either of the following?


In Reply To
CGI Url
http://domain.netfirms.com/cgi-bin/file.cgi

Your full or absolute root path is:
$ENV{'DOCUMENT_ROOT'}

Remember to use double quotes around the path.
The full path to your www directory would be:
"$ENV{'DOCUMENT_ROOT'}/www"
The full path to your cgi-bin directory would be:
"$ENV{'DOCUMENT_ROOT'}/cgi-bin"

Should I be looking at this file for anything…

http://jennyw.netfirms.com/cgi/printenv

3. My .cgi file used to be a .pl file, but I just saved it as a .cgi document? Is that ok?

Some similar questions…

Using netfirms.com
4. If I have html documents that call on .cgi docs then what folder do I put my pages in?
Do I put them all in the same folder? Or do html docs go in the /www folder and .cgi docs in the /cgi-bin ?

5.

In Reply To
You wrote…
I've written a CGI-only website. It's a small search engine for my DVD collection. And it's in german ;-) There's not a single HTML file, only two CGI scripts managing the whole site. (Plus an admin & statistics script, but these are only for me.)

How do YOU upload your .cgi scripts to netfirms.com?

In Reply To
Netfirms.com writes…

You must place all your html and image files in the 'www' directory. Only files placed in the 'www' directory can be viewed on your website. Keep all filenames in lowercase characters.

I tried uploading the .cgi email catching script you gave me to netfirms, but it didn’t work. The page wouldn’t come up when I called it in the browser.

http://members.home.net/pie3.14/email_catching.txt

And finally

6. I write my files like this…

# URL to go to if there is a problem with form input
$ErrorPage = "a_fail.html";

But some of the files have a slash ( / ) in front of the file name, so should I have a slash before the file name?

$ErrorPage = "/a_fail.html";

Thanks for taking the time,
Jenny



JennyW
journeyman

May 24, 2001, 12:03 PM

Post #28 of 123 (8300 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus!

Ok, I found answers to questions 3, 4 and 6. So disregard those.

Thanks,
Jenny



mhx
Enthusiast / Moderator

May 24, 2001, 12:29 PM

Post #29 of 123 (8298 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

I've written this offline and it took a while. I wouldn't want to delete the already answered questions... ;-)

> I had a lot of login problems with Leetch. Basically, it wouldn’t let me login to certain ftp clients once in a while.

Interesting... I'm using it for years now, and I didn't have any problems. Anyway, I think you'll be happy with WSFTP, too.

> I can’t get my Form to work. I always receive this error

First, the modifications to your file were (mostly) correct (see below).
This error mostly shows when there's a problem with the file rather than with the source code.
There were two problems: First, you have to convert all your CGI-scripts to Unix format. The file you linked to was in DOS format, meaning each line was terminated by a CR/LF sequence, while lines in Unix files are only terminated with a LF character.
To do this conversion, you can use a good text editor (e.g. UltraEdit, use File / Convert / DOS to Unix) or the following script:

Code
#!/bin/perl -w 

undef $/;
$file = shift || 'filename.cgi';

open FILE, $file or die "cannot open $file: $!\n";
$_ = <FILE>;
close FILE;

rename $file, "$file.bak";
s/\r\n/\n/g;

open FILE, ">$file" or die "cannot open $file: $!\n";
binmode FILE;
print FILE;
close FILE;

Provide it with the name of the file you'd like to convert as the first parameter.
The second problem I discovered is that CGI files at netfirms need to be mode 700 instead of mode 755. By the time I registered at netfirms, they also wrote 700 on their page. Perhaps they're making a transition here and it'll work with 755, but if you change to 700 I think you're safe.

> Am I suppose to do anything with either of the following?

No, not really. You should keep in mind that when you reference from HTML to CGI you must use cgi-bin/file.cgi instead of plain file.cgi and when you reference from CGI to HTML, you must use ../file.html instead of plain file.html. So, in your script you should rather write

Code
$ErrorPage = "../a_fail.html";

instead of

Code
$ErrorPage = "a_fail.html";

if a_fail.html is in your www directory.

> http://jennyw.netfirms.com/cgi/printenv

Are you sure with this url? Shouldn't that be http://jennyw.netfirms.com/cgi-bin/printenv.cgi?

> 3. My .cgi file used to be a .pl file, but I just saved it as a .cgi document? Is that ok?

Absolutely.

> 4. If I have html documents that call on .cgi docs then what folder do I put my pages in?
> Do I put them all in the same folder? Or do html docs go in the /www folder and .cgi docs in the /cgi-bin ?

Separate them. The cgi-bin is for CGI scripts, logs, data accessed by CGI scripts, Perl libraries, etc.
The www is for all your HTML, CSS, pictures, files that can be downloaded.

> How do YOU upload your .cgi scripts to netfirms.com?

Actually, I've written a tricky upload script in Perl. That's because first, the site has lots of images, and I don't want to keep track of which of them I have updated locally, and second, I can't (and don't want to) remember when I locally modify my scripts.
Well, my upload script first connects to the netfirms server, recursively retrieves a list of all files on the server, retrieves such a list of the local files on my machine, and checks which files are different. If files differ, it is assumed that the local files are up-to-date. These files are uploaded. If files are available locally, but not on the server, these are uploaded, too. If files are available on the server, but missing locally, these files are removed from the server.
The script also converts all my CGI scripts before uploading so they will have the right shebang line. And last but not least the script sends a chmod 700 for every uploaded CGI script.
Using this script saves me from worrying about synchronization of local and remote files and also saves my money because it significantly reduces my internet costs ;-)
If you're interested in the script, tell me. But be aware that you surely will have to modify it before you can use it. As I said it's a quite tricky sort of script.

> I tried uploading the .cgi email catching script you gave me to netfirms, but it didn’t work. The page wouldn’t come up when I called it in the browser.

Well, I also tried it and it showed up. I don't know if it actually works, but at least it showed up. Are you sure it hasn't got something to do with Unix format or mode 700?

> But some of the files have a slash ( / ) in front of the file name, so should I have a slash before the file name?

Normally files don't have slashes in front of their names ;-) The slash only indicates that the file is located in the root directory. I don't believe this is correct. But, as I mentioned above, you should reference the file from the CGI script as if it was located in the parent directory (../).

Bye,
Marcus

P.S.: There's a successor to LeechFTP, called BitBeamer (ftp://ftp.cuhk.edu.hk/.1/chinese/cpatch/ftp/bitbeamer/bitbeamer2001.exe), which has a synchronize option. This should be quite similar to my upload script, except for modifying scripts and the chmod. It's still in beta state, and I haven't tested it. Since I don't know if WSFTP has a synchronize option, perhaps this is interesting for you.

(This post was edited by mhx on May 24, 2001, 1:06 PM)


JennyW
journeyman

May 24, 2001, 8:11 PM

Post #30 of 123 (8289 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hiee Marcus. Thanks so much for the giant reply. I can’t begin to explain how much you’re helping me out!

Ok, before I start asking more questions I made a few changes to my .cgi script. Now, I’m getting my “a_fail.html” page.

I changed the following parameters on my .cgi script. They were asking for url’s, not file paths.

# URL to go to if there is a problem with form input
$ErrorPage = "http://jennyw.netfirms.com/a_fail.html";

# URL to go to when form has been successfully submitted
$ThankPage = "http://jennyw.netfirms.com/a_thanks.html";

# URL to go to if a 'foreign' referer calls the script
$EvilReferer = "http://jennyw.netfirms.com/a_fail.html";

Here’s the full script again…
http://members.home.net/pie3.14/AlphaMail.txt

Here’s my url…
http://jennyw.netfirms.com

In Reply To
You wrote…
This error mostly shows when there's a problem with the file rather than with the source code.
There were two problems: First, you have to convert all your CGI-scripts to Unix format. The file you linked to was in DOS format, meaning each line was terminated by a CR/LF sequence, while lines in Unix files are only terminated with a LF character.

How can you tell that my .cgi doc was in DOS format? What did you see?

To do this conversion, you can use a good text editor (e.g. UltraEdit, use File / Convert / DOS to Unix) or the following script:

#!/bin/perl -w

undef $/;
$file = shift || 'filename.cgi';

open FILE, $file or die "cannot open $file: $!\n";
$_ = <FILE>;
close FILE;

rename $file, "$file.bak";
s/\r\n/\n/g;

open FILE, ">$file" or die "cannot open $file: $!\n";
binmode FILE;
print FILE;
close FILE;

I can’t use Notepad or Wordpad? If so, why not?
Is UltraEdit free? I’d be looking for a free program if the above two can’t be used.

In regards to the script above
Where would I place it? Is it a separate file or does it go within the .cgi script that needs changing?
Would I use this for all DOS to Unix .cgi script conversions?

I was told that all of my .cgi scripts need to be uploaded in 'ASCII' format? Is this correct?
In WSFTP there are three options: ASCII - Binary - Auto

What is Auto?

Ohh boy here I go again, I didn’t want to ask this many questions.


In Reply To
You wrote…
The second problem I discovered is that CGI files at netfirms need to be mode 700 instead of mode 755. By the time I registered at netfirms, they also wrote 700 on their page. Perhaps they're making a transition here and it'll work with 755, but if you change to 700 I think you're safe.

What is mode 700?
Mode 755 is…
Owner – Read, Write, Execute
Other – Read, Execute
Group – Read, Execute


In Reply To
We wrote…
I tried uploading the .cgi email catching script you gave me to netfirms, but it didn’t work. The page wouldn’t come up when I called it in the browser.

Well, I also tried it and it showed up. I don't know if it actually works, but at least it showed up. Are you sure it hasn't got something to do with Unix format or mode 700?

I’ll wait ‘till I get responses from previous questions before I tackle this bugger again!

In Reply To

We wrote…

http://jennyw.netfirms.com/cgi/printenv

Are you sure with this url? Shouldn't that be http://jennyw.netfirms.com/cgi-bin/printenv.cgi?

Yes, I am positive! Check out the url!

Your upload script sounds very complicated. I think I’ll stick with the basics. It’s a little over my head!
Thanks anyway Marcus!

Jenny



mhx
Enthusiast / Moderator

May 24, 2001, 11:59 PM

Post #31 of 123 (8286 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

> I changed the following parameters on my .cgi script. They were asking for url’s, not file paths.
> # URL to go to if there is a problem with form input
> $ErrorPage = "http://jennyw.netfirms.com/a_fail.html";

Have you tried if it works with

Code
$ErrorPage = "../a_fail.html";

If it does, it's easier to reuse if you change your server.

> How can you tell that my .cgi doc was in DOS format? What did you see?

Magic ;-) No, not really, both editors I'm using (Vim and UltraEdit) display the file format, which they determine from the line terminator sequence.

> I can’t use Notepad or Wordpad? If so, why not?
> Is UltraEdit free? I’d be looking for a free program if the above two can’t be used.
> In regards to the script above
> Where would I place it? Is it a separate file or does it go within the .cgi script that needs changing?
> Would I use this for all DOS to Unix .cgi script conversions?
> I was told that all of my .cgi scripts need to be uploaded in 'ASCII' format? Is this correct?
> In WSFTP there are three options: ASCII - Binary - Auto

I'll answer all this in a single paragraph :-) First, you can use any editor you want if you transfer your scripts in ASCII mode. Even if the editor generates DOS format, uploading as ASCII will automatically convert to the format needed by the server (which is Unix format for netfirms.com).
I could have given you the hint with the ASCII format, but I so rarely use it, I just forgot about it. I always transfer all my files in binary mode, so my editors both save files in Unix format. The advantage is: Unix format files will run under Windows, but DOS format won't work under Unix.
The difference between ASCII, binary and Auto can only be noticed if a Windows machine and a Unix machine are doing FTP, since they have different text format (didn't I mention this already??). In binary mode, a file is always transferred 'as is', i.e. no single byte is changed. In ASCII mode, line terminators are changed to fit for the system a file is up- or downloaded to. Perhaps also other character conversion is done. In Auto mode, the FTP-Client tries to automatically determine if a file should be transferred in ASCII or binary mode. I'm not sure which it chooses when, because I always use binary transfer.
Concerning the Editor choice, UltraEdit is not free, but IMO the second-best Windows editor and worth its money. The best editor is Vim, although many none-hardcore-programmers may not agree with me. It's the best because it's free, has simply the best syntax highlighting features (you should see Perl code with Vim!!), and is so incredibly fast to use if you work with it often enough. Unfortunately it's no fun to learn working with Vim if you only know Word or Notepad...
Concerning my script: Either forget about it (use ASCII mode) or place it anywhere on your local machine. Don't upload it, it's useless on the server. Open a command prompt, change to the directory where the script is in, and enter something like this (if you name the script dos2ux and you want to convert the cgi-file test.cgi:

Code
perl dos2ux test.cgi

The script will create a backup of the cgi-file called test.cgi.bak and the test.cgi will afterwards be in Unix format.

> What is mode 700?
> Mode 755 is
> Owner - Read, Write, Execute
> Other - Read, Execute
> Group - Read, Execute

Little excursion on Unix file flags:

Code
   user     group     all 
-----------------------
7 5 4 <- octal representation
1 1 1 1 0 1 1 0 0 <- binary representation
r w x r w x r w x
| | `--- execute permission
| `------ write permission
`-------- read permission

r w x r x r
----- ----- -----
| | `------ Everybody can read the file
| `--------------- The group may read and execute
`------------------------ The owner has full access

Now, it should be clear that mode 700 grants all right to the user and denies permission for everyone else to do anything with the file. If you would set mode 000, even the user has no permissions, but the user (and only the user) can always change the file mode.

> Yes, I am positive! Check out the url!

Ok, that was my fault. I thought the printenv script was one you've written, but it's a netfirms script that works for all accounts. I've written the printenv script on my own, so I was a bit mislead here...

> Well, I also tried it and it showed up. I don't know if it actually works, but at least it showed up. Are you sure it hasn't got something to do with Unix format or mode 700?
> I’ll wait ‘till I get responses from previous questions before I tackle this bugger again!

I just put the file into my cgi-bin directory. Test it, if you like, it's here.

> Your upload script sounds very complicated. I think I’ll stick with the basics. It’s a little over my head!

I'll send it to you as soon as I get my hands on it again ;-)

Bye,
Marcus



JennyW
journeyman

May 25, 2001, 7:16 AM

Post #32 of 123 (8280 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

 
Hi mhx - a.k.a. Marcus,


In Reply To
You wrote…

First, you can use any editor you want if you transfer your scripts in ASCII mode. Even if the editor generates DOS format, uploading as ASCII will automatically convert to the format needed by the server (which is Unix format for netfirms.com).
I could have given you the hint with the ASCII format, but I so rarely use it, I just forgot about it. I always transfer all my files in binary mode, so my editors both save files in Unix format. The advantage is: Unix format files will run under Windows, but DOS format won't work under Unix.

Ok, so what you’re saying is I don’t have to worry about text editors, as long as I upload my .cgi scripts in ASCII format then I’m ok?

The thing is I’ve uploaded my .cgi script to netfirms.com as ASCII format and I got the “a_fail.html” (error) page. However, I set my cgi-bin and .cgi scripts to chmod 755.

Do I have to set all my .cgi scripts to chmod 700?
Do I set my .cgi-bin to chmod 700 too?


In Reply To
You also wrote

Concerning my script: Either forget about it (use ASCII mode) or place it anywhere on your local machine. Don't upload it, it's useless on the server. Open a command prompt, change to the directory where the script is in, and enter something like this (if you name the script dos2ux and you want to convert the cgi-file test.cgi:
perl dos2ux test.cgi
The script will create a backup of the cgi-file called test.cgi.bak and the test.cgi will afterwards be in Unix format.

So if I do this at the command prompt then I won’t need to upload in ASCII, I can upload in binary insetad?


In Reply To
We wrote…
Yes, I am positive! Check out the url!

http:// http://jennyw.netfirms.com/cgi/printenv

Ok, that was my fault. I thought the printenv script was one you've written, but it's a netfirms script that works for all accounts. I've written the printenv script on my own, so I was a bit mislead here...

What should I do with the url above? What is its function?

In Reply To
You wrote…
Well, I also tried it and it showed up. I don't know if it actually works, but at least it showed up. Are you sure it hasn't got something to do with Unix format or mode 700?
> I’ll wait ‘till I get responses from previous questions before I tackle this bugger again!

I just put the file into my cgi-bin directory. Test it, if you like, it's here.

I noticed your script has a .cgi extension.

I read this in netfirms…

You must place all your html and image files in the 'www' directory. Only files placed in the 'www' directory can be viewed on your website. Keep all filenames in lowercase characters. Your main page should be called index.html or index.htm.The webserver first looks for index.html and if not there it looks for index.htm

Why does netfirms.com write…

Only files placed in the 'www' directory can be viewed on your website.

If only files placed in the www directory can be viewed then how are YOU able to put .cgi scripts in the cgi-bin and view them (below)?

http://mhx.netfirms.com/cgi-bin/emtest.cgi

Thanks for the great responses,
Jenny



mhx
Enthusiast / Moderator

May 25, 2001, 8:27 AM

Post #33 of 123 (8279 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

> Ok, so what you’re saying is I don’t have to worry about text editors, as long as I upload my .cgi scripts in ASCII format then I’m ok?

That's right!

> The thing is I’ve uploaded my .cgi script to netfirms.com as ASCII format and I got the a_fail.html” (error) page. However, I set my cgi-bin and .cgi scripts to chmod 755.

That's perfect, because it shows your cgi-script is actually running. If it wouldn't be running, you'd get a Server Error instead of your a_fail.html. It's not so perfect because it shows that something else is wrong...
Also, you don't have to chmod your files to 700, as they seem to work with 755.

> Do I set my .cgi-bin to chmod 700 too?

You shouldn't change the mode of your cgi-bin directory.

> So if I do this at the command prompt then I won’t need to upload in ASCII, I can upload in binary insetad?

That's right. But beware that when you're using Notepad, you won't be able to view the converted files correctly.
So I really recommend to use either ASCII upload or get a text editor supporting Unix file format.

> What should I do with the url above? What is its function?

Did you run the script? It shows which environment variables are set by the Apache server. You can access the environment variables in Perl using the %ENV hash table. But in most cases, this is not really needed. On my page, I only use it to display the Apache version.

> I noticed your script has a .cgi extension.

Well, yes. Just to show it's a CGI script... Smile

> Only files placed in the 'www' directory can be viewed on your website.
> If only files placed in the www directory can be viewed then how are YOU able to put .cgi scripts in the cgi-bin and view them (below)?
> http://mhx.netfirms.com/cgi-bin/emtest.cgi

That's because you cannot view a CGI script. You can only view its output. Whatever you print in your CGI script will be used to generate a temporary HTML file that is displayed by the webserver. This temporary file is nowhere but in the server's memory.
It's quite ok that your cannot view anything in the cgi-bin directory. If you could, everyone could steal your CGI scripts, or Amazon's, or IBM's, or ...

Hmmm, really short answers this time! Hope they help anyway...

Bye,
Marcus



JennyW
journeyman

May 25, 2001, 9:39 AM

Post #34 of 123 (8278 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hiee!! Friday!!

In Reply To
We wrote…
> The thing is I’ve uploaded my .cgi script to netfirms.com as ASCII format and I got the a_fail.html” (error) page. However, I set my cgi-bin and .cgi scripts to chmod 755.

That's perfect, because it shows your cgi-script is actually running. If it wouldn't be running, you'd get a Server Error instead of your a_fail.html. It's not so perfect because it shows that something else is wrong...
Also, you don't have to chmod your files to 700, as they seem to work with 755.

> Do I set my .cgi-bin to chmod 700 too?

You shouldn't change the mode of your cgi-bin directory.

I DID change the mode of my actual cgi-bin to 755. Why is this wrong?
Should I only be setting the mode for the .cgi scripts?

Should I take this line out of the .cgi script?


Code
use CGI::Carp qw(fatalsToBrowser);

The above is right under the Shebang line.

I only adjusted to the shebang line, set the variables (at beginning of doc) and I added the line listed above.

Maybe it’s my email variables? The script directed me to do the following…

# E-mail address to send intake form to (your address)
# If not using PERL 5, escape the @ thus: \@ instead of @
$YourEmail = 'themustache@hotmail.com';

I have Perl 5.004_02 so I didn’t use the \@. That’s right isn’t it?

Other than those possible problems I don’t know what could be wrong.

Here’s the .cgi script’s url…

http://members.home.net/pie3.14/AlphaMail.txt


In Reply To
We wrote…
http://jennyw.netfirms.com/cgi/printenv

> What should I do with the url above? What is its function?

Did you run the script? It shows which environment variables are set by the Apache server. You can access the environment variables in Perl using the %ENV hash table. But in most cases, this is not really needed. On my page, I only use it to display the Apache version.

I didn’t run the script. I know you said it’s not really important, but I’m curious - how would I be able to run the script?


In Reply To
We wrote…
> I noticed your script has a .cgi extension.

Well, yes. Just to show it's a CGI script...

> Only files placed in the 'www' directory can be viewed on your website.
> If only files placed in the www directory can be viewed then how are YOU able to put .cgi scripts in the cgi-bin and view them (below)?
> http://mhx.netfirms.com/cgi-bin/emtest.cgi

That's because you cannot view a CGI script. You can only view its output. Whatever you print in your CGI script will be used to generate a temporary HTML file that is displayed by the webserver. This temporary file is nowhere but in the server's memory.

I understand! So I should be able to take the email catching script you gave me http://members.home.net/pie3.14/email_catching.txt and upload it to netfirms.com and run it?

Thanks again!
Jenny



mhx
Enthusiast / Moderator

May 25, 2001, 10:45 AM

Post #35 of 123 (8276 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

> I DID change the mode of my actual cgi-bin to 755. Why is this wrong?

I didn't say it's wrong, I just meant it could be better to leave it the way it was. It guess netfirms people know why they give a certain directory certain permissions.

> Should I only be setting the mode for the .cgi scripts?

Yes.

> Should I take this line out of the .cgi script?
> use CGI::Carp qw(fatalsToBrowser);

No. Better leave it in, because it may issue useful information if there's something wrong with your script.
You can take it out if the script works fine, but you can also leave it in.

> Maybe it’s my email variables? The script directed me to do the following…
> # E-mail address to send intake form to (your address)
> # If not using PERL 5, escape the @ thus: \@ instead of @
> $YourEmail = 'themustache@hotmail.com';
> I have Perl 5.004_02 so I didn’t use the \@. That’s right isn’t it?

Yes, that's right if you only use single quotes (is this ' called single quote in english?). If you use double quotes (") you must put a backslash in front of the @.

> I didn’t run the script. I know you said it’s not really important, but I’m curious - how would I be able to run the script?

Just enter the url! Simply visit http://jennyw.netfirms.com/cgi/printenv.

> I understand! So I should be able to take the email catching script you gave me http://members.home.net/pie3.14/email_catching.txt and upload it to netfirms.com and run it?

Exactly. Just name it catchmail.cgi put it in you cgi-bin and visit http://jennyw.netfirms.com/cgi-bin/catchmail.cgi.

I've modified your script a bit, so if you could tell me what exactly the output is if you run the script now, I'll perhaps be able to tell you what's wrong.
Instead of leading you to your a_fail.html page, it will now display an error describing why it failed. I've attached the modfied file here.

Bye,
Marcus



JennyW
journeyman

May 25, 2001, 11:53 AM

Post #36 of 123 (8275 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hiee!

You wrote...

In Reply To
is this ' called single quote in english?

Yes it is! Wowee, I actually answered a question! lol!

You wrote…

In Reply To
I've modified your script a bit, so if you could tell me what exactly the output is if you run the script now, I'll perhaps be able to tell you what's wrong.
Instead of leading you to your a_fail.html page, it will now display an error describing why it failed. I've attached the modfied file here.

Thanks for the adjustments Marcus!
I’m unable to run the script now, but I’ll get to it very soon and let you know the results!

Out of curiosity what changes did you make to the script?
The only script adjustments I noticed were the following lines…

You added

Code
use CGI qw/:standard/;


Code
print header;

You deleted

Code
# location of Perl (above) - check your doc or ask admin

Thanks Marcus!
Jenny



mhx
Enthusiast / Moderator

May 25, 2001, 12:24 PM

Post #37 of 123 (8275 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

>> is this ' called single quote in english?
> Yes it is! Wowee, I actually answered a question! lol!

Thanks, I really wasn't sure about it...

>Out of curiosity what changes did you make to the script?

Oh, it's more than you've noticed. I mainly changed the redirection thing at the bottom of the file. Look for a line

Code
=for nobody

That's where I commented out the original code. Below is my replacement code. You'll see that I have just given the error function a string parameter which I use to give an error explanation. Instead of redirection, this explanation is printed out as HTML. Simply scroll to the end of the script and you'll see the changes.

Bye,
Marcus



mhx
Enthusiast / Moderator

May 25, 2001, 1:45 PM

Post #38 of 123 (8272 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

it's me again. As I promised, I have attached to this post my upload script. Perhaps you can just draw some ideas from it.

And, by the way, here's an example of how Vim, my favourite editor, would display a Perl script:


Code
#!/usr/bin/perl 
use CGI::Carp qw(fatalsToBrowser);
use CGI qw/:standard/;
use strict;

print header;

unless( param() ) # no parameters? => display form!
{
print start_html(-title => "Most Basic CGI Input Page"), start_form;
print "email, please: ", textfield(-size => 25, -name => 'Email_Address');
print submit('Submit'), end_form;
}
else # we have parameters => display results!
{
print start_html(-title => "Catching an email");
print p("Address is: ", param('Email_Address'));
}

print end_html;

Isn't that much more readable than Notepad?

Bye,
Marcus



JennyW
journeyman

May 25, 2001, 7:24 PM

Post #39 of 123 (8271 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus,

Ok, I tested the script you updated for me.
Here’s the url of the script (I made a new page)…

http://jennyw.netfirms.com/form_test.html

Here’s the results I received after entering an email address…

Code
CheckEmailAddressFormat: No @ !

My email address looked like this in the .cgi script…


Code
'themustache@hotmail.com'

So, I added a backslash \ in front of the @ sign and retested…

'themustache\@hotmail.com'

I received the same message…

Code
CheckEmailAddressFormat: No @ !

I changed it back – took out the backslash

Here’s the full .cgi code, including your adjustments…
http://members.home.net/pie3.14/alphamail_002.txt

Does the problem have anything to do with my <html> Form code (below)?

Code
<FORM NAME="Myform" ACTION="/cgi-bin/alphamail_002.cgi" METHOD="POST">

A few posts ago you we wrote…

In Reply To
> I changed the following parameters on my .cgi script. They were asking for url’s, not file paths.
> # URL to go to if there is a problem with form input
> $ErrorPage = "http://jennyw.netfirms.com/a_fail.html";

Have you tried if it works with
$ErrorPage = "../a_fail.html";
If it does, it's easier to reuse if you change your server

So I changed the path in .cgi script from http://jennyw.netfirms.com/a_fail.html

to…


Code
/a_fail.html

Is this correct? My settings are presently using this path.

I also tried…


Code
/cgi-bin/fail.html


This path didn’t work on the original script (WITHOUT your modifications), but it worked on the script WITH your modifications. Why is this happening?

Script WITHOUT your modifications…http://members.home.net/pie3.14/AlphaMail.txt

Script WITH your modifications…http://members.home.net/pie3.14/alphamail_002.txt

I just thought I’d let you know that I got your email catching script working.
Here’s the url…Thanks!

http://jennyw.netfirms.com/cgi-bin/mhx_email_test.cgi

Also, thanks for upload script. I’m not sure that I’ll be able to use it or if it suits my needs, but thanks!

Jenny



mhx
Enthusiast / Moderator

May 26, 2001, 12:40 AM

Post #40 of 123 (8269 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

I think we're getting very close to solving your email problems Smile.

> Does the problem have anything to do with my <html> Form code (below)?

Without looking any further at the cgi script, seeing the error it suddenly came to my mind: Do we feed the right stuff into the cgi script? No, we don't! Yes, it has to do with your HTML code.
What's just missing is the text fields for Name, Email and Message. Because the email address is checked first, the script stops immediately as it doesn't discover an @ sign, because there simply is no Email field in your form.
I'm going to modify your form, so it will fit for your script. But first of all, the other things:

> 'themustache\@hotmail.com'

This is definitely wrong. Keep it without the backslash. The script doesn't mean your address, but the address of the person using the form.

> So I changed the path in .cgi script from http://jennyw.netfirms.com/a_fail.html to
> /a_fail.html
> Is this correct? My settings are presently using this path.

No, as I said, you must change it to

Code
../a_fail.html

The two dots are absolutely neccessary.

> I also tried
> /cgi-bin/fail.html
> This path didn’t work on the original script (WITHOUT your modifications), but it worked on the script WITH your modifications. Why is this happening?

The path is wrong. So the original script fails. My modified script works because I took all the a_fail.html stuff out Wink.

> Also, thanks for upload script. I’m not sure that I’ll be able to use it or if it suits my needs, but thanks!

I guess, if you're a bit more into Perl, you'll be able to use it.

But now for your HTML file modifications, here comes the step-by-step guide to success!
First, use the old cgi-script. My script with the modifications was good enough for showing me the problem, but unfortunately it fails always. (I also know why! Crazy)
Be sure you have all variables set correctly, such as the fail and thanks page.
Now, upload the following HTML code and try it. Be sure to enter something in all three fields, and be sure to give it a valid email address.

Code
<html> 
<head>
<title>Jenny's second ;-) .cgi test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#333333">

<form action="cgi-bin/alphamail_002.cgi" method="POST">
<table>
<tr>
<td><font color="#CCCC00">Your Name:</font></td>
<td><input type="TEXT" size=30 name="Name"></td>
</tr>
<tr>
<td><font color="#CCCC00">Your Email:</font></td>
<td><input type="TEXT" size=30 name="Email"></td>
</tr>
<tr>
<td><font color="#CCCC00">Your Message:</font></td>
<td><textarea name="Message" rows=12 cols=40></textarea></td>
</tr>
</table>
<input type="SUBMIT" value="Form Submission" name="SUBMIT">
</form>

<p>
<font color="#CCCC00" face="Arial, Helvetica, sans-serif" size="1">
Jenny's slightly modified Form test...
</font>
</p>
<p>
<font color="#CCCC00" face="Arial, Helvetica, sans-serif" size="1">
05_26_01
</font>
</p>

</body>
</html>

And tell about me your results, please.

Bye,
Marcus



JennyW
journeyman

May 26, 2001, 4:35 PM

Post #41 of 123 (8258 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi! Having a good weekend Marcus!

I used your <html> script with the original .cgi script and unfortunately my test was unsuccessful. I receive the FAIL page.
Here’s my page…

http://jennyw.netfirms.com/form_test_05_26_01.html

Here’s my .cgi script…

http://members.home.net/pie3.14/AlphaMail.txt

CGI script – I made the adjustments below…

Code
../a_fail.html


Code
../a_thanks.html

I even tried inserting the url’s for the “thanks”, “fail” and “EvilReferer” pages in the .cgi script, but I was still received the FAIL page.

In Reply To
What's just missing is the text fields for Name, Email and Message. Because the email address is checked first, the script stops immediately as it doesn't discover an @ sign, because there simply is no Email field in your form…
…Now, upload the following HTML code and try it. Be sure to enter something in all three fields, and be sure to give it a valid email address.

Ok, here’s what I had in the first part of my Form…

<form action="cgi-bin/alphamail.cgi" method="POST">
<table>
<tr>
<td><font color="#CCCC00">Your Name:</font></td>
<td><input type="TEXT" size=30 name="EnterName"></td>
</tr>
<tr>
<td><font color="#CCCC00">Your Email:</font></td>
<td><input type="TEXT" size=30 name="themustache@hotmail.com"></td>
</tr>
<tr>
<td><font color="#CCCC00">Your Message:</font></td>
<td><textarea name="TypeYourMessage" rows=12 cols=60></textarea></td>


What did I do wrong?

A few questions about the above…

<td><input type="TEXT" size=30 name="EnterName"></td>
and
<td><textarea name="TypeYourMessage" rows=12 cols=60></textarea></td>

Can I put spaces in the name fields above?
Example…Instead of having…

Code
TypeYourMessage

…can I write…

Code
Type Your Message

Also, I noticed that you had the ACTION of the form written like this…


Code
ACTION ="cgi-bin/alphamail_002.cgi"

Is there suppose to be a slash / in front of the cgi-bin?
(I added the slash and the script still didn’t work – I took it back out)


Code
ACTION="/cgi-bin/alphamail_002.cgi"


In Reply To
> 'themustache\@hotmail.com'

This is definitely wrong. Keep it without the backslash. The script doesn't mean your address, but the address of the person using the form.

I not clear on this. This .cgi script writes…

In Reply To
# E-mail address to send intake form to (your address)
# If not using PERL 5, escape the @ thus: \@ instead of @
$YourEmail = 'themustache@hotmail.com';

What does the address of the person using the form have to do with anything in the above?

In Reply To
No, as I said, you must change it to

Code
../a_fail.html

The two dots are absolutely neccessary.

Why are the two dots necessary?

In Reply To
../a_fail.html

Do I use this for every server I have my site on?

In Reply To
First, use the old cgi-script. My script with the modifications was good enough for showing me the problem, but unfortunately it fails always. (I also know why!)

Why does it always fail?

Thanks again!
Jenny



mhx
Enthusiast / Moderator

May 27, 2001, 1:00 AM

Post #42 of 123 (8250 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

well, before I start answering your questions: IT WORKS!
I've just uploaded my modified HTML page, three dummy pages (a_fail.html, a_evil.html, a_thanks.html). The only changes I've made had to do with uploading and testing. I've replaced your email with mine (I can't check yours...), I've added my host to the list of referers, I've added the evil referer page and I renamed the script to alphamail.cgi.
If you like, you can test it. Enter your own email address in the form and you should receive a reply immediately. I've sent a mail to myself, and received the mail as well as the reply.

> CGI script I made the adjustments below
> ../a_fail.html
> ../a_thanks.html
> I even tried inserting the url’s for the thanks, fail and EvilReferer pages in the .cgi script, but I was still received the FAIL page.

Again, if you receive the fail page, your script works and fails not because these URLs are wrong.

> What did I do wrong?

Your HTML page couldn't work, because it's simply not what I have sent to you. You changed the names of the form elements, and so the script doesn't find these elements. You've used EnterName instead of Name, themustache@hotmail.com instead of Email and TypeYourMessage instead of Message. I guess that's all that went wrong. You could do me a favor and answer another question: Why did you change nearly the only thing that could make it all fail before testing with what I've sent you?

> Can I put spaces in the name fields above?

**NO** YOU MAY NOT EVEN MODIFY THESE!!! What are you trying to do? If you want to put some default text into the input fields, that's done like this:

Code
<input type="TEXT" size=30 name="Email" value="mhx@gmx.de"> 
<textarea name="Message" rows=12 cols=60>Enter your Message here</textarea>

> ACTION ="cgi-bin/alphamail_002.cgi"
> Is there suppose to be a slash / in front of the cgi-bin?
> (I added the slash and the script still didn’t work I took it back out)
> ACTION="/cgi-bin/alphamail_002.cgi"

No, you don't need a slash. Again, your script works, the HTML form is wrong.

> The script doesn't mean your address, but the address of the person using the form.
> I not clear on this. This .cgi script writes
> # E-mail address to send intake form to (your address)
> # If not using PERL 5, escape the @ thus: \@ instead of @
> $YourEmail = 'themustache@hotmail.com';
> What does the address of the person using the form have to do with anything in the above?

My quote (The script doesn't mean your address, but the address of the person using the form.) was just out of context.
What I was trying to say: You got an error from the script telling you that there was no @ in the email address. You changed your email address in the script. But your email address isn't even checked by the script. What the script is checking is the address the user has entered in the HTML form. Since your form was wrong, the script delivered an error. Changing your email address in the script by adding a backslash (which is wrong in this place) doesn't have any effect on the error you get. I hope this is now clear. Smile

> Why are the two dots necessary?

Um, that's a bit tough to say... From the webserver's point of view, the cgi-bin directory is a subdirectory of the www directory. That's why you can access CGI scripts from HTML located in the www directory by using a link cgi-bin/whatever.cgi.
So, in exactly the same way, the www directory is a parent directory to the cgi-bin directory. And the two dots .. mean nothing but parent directory. So anytime you want to access a HTML file located in the www directory from within the cgi-bin directory, do it like this.
I hope I didn't confuse you with this...

> Do I use this for every server I have my site on?

Yes, I guess this should work for most servers.

> Why does it always fail?

Oooo, I'm sure this will confuse you, but anyway, you asked for it.
I've used the CGI module in the modified script. As soon as this module is used, it takes over the parsing of the form data, similarly to the ReadParse function in the script. Unfortunately, when this is done, there's nothing left to parse for ReadParse. And thus, the script will always fail because it never receives any data from even a valid HTML form. Nevertheless the modified script was useful, because it reminded me of the HTML form problem.

Bye,
Marcus



JennyW
journeyman

May 27, 2001, 3:11 PM

Post #43 of 123 (8234 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hey Marcus!
Well, everything works! Thank you so much. Your help is invaluable! However, this doesn’t mean I’m gonna stop bugging you!

Here’s my url if you wanna try the Form.

Jenny’s FORM

In Reply To
Your HTML page couldn't work, because it's simply not what I have sent to you. You changed the names of the form elements, and so the script doesn't find these elements. You've used EnterName instead of Name, themustache@hotmail.com instead of Email and TypeYourMessage instead of Message. I guess that's all that went wrong. You could do me a favor and answer another question: Why did you change nearly the only thing that could make it all fail before testing with what I've sent you?

I changed the NAME, EMAIL and MESSAGE fields because I misinterpreted an earlier message you wrote.

In Reply To
Now, upload the following HTML code and try it. Be sure to enter something in all three fields, and be sure to give it a valid email address.

I thought you meant enter something in the three fields (NAME, EMAIL and MESSAGE) within the FORM’s <html> code. It was a mistake totally on my part. I now understand you meant the three fields in the browser window.

In Reply To
> Can I put spaces in the name fields above?

**NO** YOU MAY NOT EVEN MODIFY THESE!!! What are you trying to do?

I totally made a mistake.

A few questions…

I don’t want the user to go to a THANK YOU page. Do I just comment out the second line below?

# URL to go to when form has been successfully submitted
$ThankPage = "../a_thanks.html";


I also don’t want an Autoresponse sent out.

Do I just comment out the following…

sub SendAutoReply {
open (MAIL,"|$MailProgram -t");
print MAIL "To: $Email\n";
print MAIL "From: $YourEmail\n";
print MAIL "Subject: $Subject\n";
print MAIL "$Header\n";
print MAIL "$Date\n\n";
print MAIL "$Subject\n\n";
print MAIL "You sent the following:\n\n";
print MAIL "==============================\n\n";
print MAIL "Name: $Name\n";
print MAIL "Email: $Email\n\n";
print MAIL "Message:\n\n";
print MAIL "$Message\n\n";
print MAIL "==============================\n\n";
print MAIL "$TailMessage\n\n";
print MAIL "Best regards,\n\n\n";
print MAIL "$Signature1\n";
print MAIL "$Signature2\n\n";
close (MAIL);
}



Thanks so much!
Jenny



mhx
Enthusiast / Moderator

May 27, 2001, 10:53 PM

Post #44 of 123 (8230 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,


In Reply To
Well, everything works! Thank you so much. Your help is invaluable! However, this doesn’t mean I’m gonna stop bugging you!

I've just been testing your e-mailer and it worked perfectly. Smile

In Reply To
I changed the NAME, EMAIL and MESSAGE fields because I misinterpreted an earlier message you wrote.
Now, upload the following HTML code and try it. Be sure to enter something in all three fields, and be sure to give it a valid email address.
I thought you meant enter something in the three fields (NAME, EMAIL and MESSAGE) within the FORM’s <html> code. It was a mistake totally on my part. I now understand you meant the three fields in the browser window.

Oooo, now I get it!!! Sorry I was confusing you. Perhaps it's due to my low-end english...

Concerning your questions, I'm going to have a look when I'm back home. Anyway, I'm giving a rough guess here, perhaps it'll work. Wink


In Reply To
I don’t want the user to go to a THANK YOU page. Do I just comment out the second line below?

That wouldn't be a good idea, because you would end up nowhere. You've got to send the user somewhere. Simply enter the URL (can also be relative URL with '../') of the page you want the user to be sent to instead of '../a_thanks.html'.


In Reply To
I also don’t want an Autoresponse sent out.
Do I just comment out the following…

That wouldn't be a good idea either, because the script wouldn't run anymore... But it's not far from the truth! Just comment this section out, as you proposed, but additionally, look through the script for any other occurrence of SendAutoReply. There should be only one, shortly after the section where you are told not to modify anything below, as far as I can recall. Comment this line out, too, and you should no longer be sending auto-replies.

Anyway, I don't think it's good to give no feedback to the user. I guess this is uncritical here, but I personally like to have feedback on forms I filled out, even if it costs me some clicks. That's why I like amazon, they tell me that my order has been placed on their page, they send me an email that it has been placed and what I've ordered, and they send me mail when they send my stuff out, so I always know what's going on.
Personally, I'd keep the thankyou page (just redesign it a bit, it's really boring) and I'd make the autoreply optional. So a user can decide whether he wants to receive a copy of what he's sending you or not. This can be disabled by default. If you're interested in how to do this, just tell me.

Bye,
Marcus



JennyW
journeyman

May 28, 2001, 4:13 PM

Post #45 of 123 (8226 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus,

In Reply To
Oooo, now I get it!!! Sorry I was confusing you. Perhaps it's due to my low-end english...

No, you weren’t confusing me. I was confusing myself. You explain things better than 99 per cent of the people I’ve talked with. You also have better English than most of the people I’m around. You’re very thorough, which is great!

In Reply To
I don’t want the user to go to a THANK YOU page. Do I just comment out the second line below?

That wouldn't be a good idea, because you would end up nowhere. You've got to send the user somewhere. Simply enter the URL (can
also be relative URL with '../') of the page you want the user to be sent to instead of '../a_thanks.html'.

I don’t want the user to be sent to a thank you page. I don’t like that kind of thing. I have a great dhtml script that I’m gonna use for my forms.

If you’re interested here it is…

DHTML Form enhancement

In due time I have a few things I’d like to add to that DHTML script.


In Reply To
You've got to send the user somewhere. Simply enter the URL (can also be relative URL with '../') of the page you want the user to be sent to instead of '../a_thanks.html'.

Does the above mean that I can also enter…

../a_some_page.html ?

In Reply To
I also don’t want an Autoresponse sent out.
Do I just comment out the following…

That wouldn't be a good idea either, because the script wouldn't run anymore...

Are you pulling my leggy?

In Reply To
Personally, I'd keep the thankyou page (just redesign it a bit, it's really boring) and I'd make the autoreply optional. So a user can decide whether he wants to receive a copy of what he's sending you or not. This can be disabled by default. If you're interested in how to do this, just tell me.

Yes, that’s a great idea. I’d love to know how to make the auto-reply optional! That would totally suit the user and my needs.

Thanks so much!
Jenny



mhx
Enthusiast / Moderator

May 28, 2001, 10:59 PM

Post #46 of 123 (8218 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

In Reply To
You explain things better than 99 per cent of the people I’ve talked with. You also have better English than most of the people I’m around.

Thanks a lot, I'll give part of this back to my english teachers. Seems they did quite a good job... Wink

In Reply To
I don’t want the user to be sent to a thank you page. I don’t like that kind of thing. I have a great dhtml script that I’m gonna use for my forms.
If you’re interested here it is…
DHTML Form enhancement
In due time I have a few things I’d like to add to that DHTML script.

You mean that demo with the automatically disabling buttons? Ok, this might be a good solution!

In Reply To
Does the above mean that I can also enter…
../a_some_page.html ?

Exactly that is what it meas. You could also name it ../hello.html or even justanotherscript.cgi.

In Reply To
That wouldn't be a good idea either, because the script wouldn't run anymore...
Are you pulling my leggy?

I really wish I'd understand that. Unfortunately, my english orthography is far better than my english idioms are.

In Reply To
Yes, that’s a great idea. I’d love to know how to make the auto-reply optional! That would totally suit the user and my needs.

Ok, this means you've got to modify the form and the script. It shouldn't be a big thing, but I'm going to test it first before I start explaining it to you.

Bye,
Marcus




mhx
Enthusiast / Moderator

May 29, 2001, 2:13 PM

Post #47 of 123 (8209 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

I just figured out how to implement the optional auto-reply. It's easier than I expected!
You only have to modify a single line in the alphamail.cgi script. Search the line

Code
&SendAutoReply;

(must be near line 90 in the script). I think it's commented out in your script since you didn't like the auto-reply. Replace this line by

Code
&SendAutoReply if exists $in{'WantAutoReply'};

You also have to put the whole SendAutoReply function back in in case you commented this out, too. That's everything for the cgi script.
Now, let's add the neccessary code to the HTML form. Just add the line

Code
<input type=checkbox name="WantAutoReply">Send me a copy of my mail!

anywhere you like it to appear, but inside the <form> tag. I've put it there to test it:

Code
    <tr> 
<td><font color="#CCCC00">Your Message:</font></td>
<td><textarea name="Message" rows=12 cols=40>Enter your message!</textarea></td>
</tr>
<tr>
<td></td>
<td><input type=checkbox name="WantAutoReply"><font color="#CCCC00">Send me a copy of my mail!</font></td>
</tr>

</table>
<input type="SUBMIT" value="Form Submission" name="SUBMIT">

So it will appear right below the message text box.
Yes, that's all. I was also surprised how simple it was. Smile Much fun with testing this, let me know if it works for you.

Bye,
Marcus



JennyW
journeyman

May 29, 2001, 6:19 PM

Post #48 of 123 (8207 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus!

Wow! That’s great! Your script adjustment worked nicely!

Here’s my page…

http://jennyw.netfirms.com/form_test_05_29_01.html

If you wanna take a look at the adjustment, here’s my .cgi script…

http://jennyw.netfirms.com/alphamail_new.txt

I have a question.
Below my email Form, I inserted a short display Form. When you press “Print msg” the word, “message” pops up.

I want this same action to take place on the email Form you kindly helped me with.

When I press “Form Submission” I want a message to display (Example: Thank You).

Do you know how I can do this? I tried adjusting the <html>, but was unsuccessful. If you’re unsure it’s definitely OK. You’ve been so helpful!


In Reply To
>That wouldn't be a good idea either, because the script wouldn't run anymore...
>>Are you pulling my leggy?

>>>I really wish I'd understand that. Unfortunately, my english orthography is far better than my english idioms are.

Regarding…
Are you pulling my leggy?

What I meant was, “Are you serious?

Thanks again and again and again!
Jenny



mhx
Enthusiast / Moderator

May 29, 2001, 10:59 PM

Post #49 of 123 (8203 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

Nice to see it works. I didn't really test it... Wink

In Reply To
Wow! That’s great! Your script adjustment worked nicely!

Here’s my page…

http://jennyw.netfirms.com/form_test_05_29_01.html

Just another question by myself: Do you use a tool for creating your HTML, like Frontpage or Dreamweaver? Or do you write it by hand, using an editor? I'm just wondering because I see all these <div>'s and really long <font> specs, which I rarely use. I prefer a good style sheet over having tons of <font> tags in the HTML, which then are also hard to keep consistent. But that's only personal interest.

In Reply To
When I press “Form Submission” I want a message to display (Example: Thank You).

Do you know how I can do this? I tried adjusting the <html>, but was unsuccessful. If you’re unsure it’s definitely OK. You’ve been so helpful!

I'd guess that's a slightly bigger problem now. The problem is, if you hit submit and thus the cgi-script is being activated, the script redirects you to some other - or even the same - page. This means the current page (the one with your forms) disappears, and is loaded again after completion of the cgi-script (if your forms page is entered where currently your thankyou page is entered in the script). Nevertheless, you information entered in that page is lost.
I now have two ideas. One is that, perhaps, the cgi-script needn't do a redirection. But I don't think this is possible, because the script must do anything, I guess. But I'll figure this out.
The other thing that comes to my mind would mean integrating your HTML form into the cgi script. This would definitely work, and you would have a lot more possibilities. But it would also mean to say goodbye to your HTML design tools, because AFAIK they don't support integration of HTML into cgi-scripts.
Well, unfortunately no one-liner this time. But I can try to get something working if you like.

Bye,
Marcus

P.S.: Thanks for the explanation. I guessed into that direction from context, but I wasn't sure...



JennyW
journeyman

May 30, 2001, 6:26 AM

Post #50 of 123 (8199 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hiee!

In Reply To
Just another question by myself: Do you use a tool for creating your HTML, like Frontpage or Dreamweaver? Or do you write it by hand, using an editor? I'm just wondering because I see all these <div>'s and really long <font> specs, which I rarely use.

Yes, I use Dreamweaver. However, I also do some basic editing myself.

In Reply To
>>When I press “Form Submission” I want a message to display (Example: Thank You).

>>Do you know how I can do this? I tried adjusting the <html>, but was unsuccessful. If you’re unsure it’s definitely OK. You’ve been so helpful!

>I'd guess that's a slightly bigger problem now. The problem is, if you hit submit and thus the cgi-script is being activated, the script redirects you to some other - or even the same - page. This means the current page (the one with your forms) disappears, and is loaded again after completion of the cgi-script (if your forms page is entered where currently your thankyou page is entered in the script). Nevertheless, you information entered in that page is lost.

Well, I’ve decided that my page IS gonna re-direct to another page (Example…Thank You page). After someone presses “Form Submission” I still want a message to pop up (on the Form page).

I’m assuming that since my page will be re-directing that I’ll be able to get this message to appear?

The following dating site has a good example of the pop-up message I’m talking about.
If you scroll to the bottom of the screen you’ll see the Form buttons (Search Current Ads) I’m talking about.
Blinddate.com


In Reply To
The other thing that comes to my mind would mean integrating your HTML form into the cgi script. This would definitely work, and you would have a lot more possibilities. But it would also mean to say goodbye to your HTML design tools, because AFAIK they don't support integration of HTML into cgi-scripts.

Well, if I ever decide to integrate my html within a .cgi document then can’t I just do all my html formatting in say, Dreamweaver and then cut and paste it into my .cgi document (Example… <<ENDHTML … ENDHTML)?

What is AFAIK?


Thanks,
Jenny



mhx
Enthusiast / Moderator

May 30, 2001, 6:56 AM

Post #51 of 123 (6985 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,


In Reply To
Well, I’ve decided that my page IS gonna re-direct to another page (Example…Thank You page). After someone presses “Form Submission” I still want a message to pop up (on the Form page).

I’m assuming that since my page will be re-directing that I’ll be able to get this message to appear?

The following dating site has a good example of the pop-up message I’m talking about.
If you scroll to the bottom of the screen you’ll see the Form buttons (Search Current Ads) I’m talking about.
Blinddate.com

Ok, now I know what you want. I've had a look at the source of the site you've linked to. It's the solution I thought of first when reading your last post, but then it occurred to me that it would behave exactly like it does on that page. But if you want it that way, perfect! Have you had a look at the source yet, or do you need some explanation?

In Reply To
Well, if I ever decide to integrate my html within a .cgi document then can’t I just do all my html formatting in say, Dreamweaver and then cut and paste it into my .cgi document (Example… <<ENDHTML … ENDHTML)?

That's usually the bad way, nevertheless it's a possible way. It's bad because it's nearly impossible to read the resulting mixture of HTML and Perl. The good way is to use the CGI package instead of HTML, or at least to put the HTML code into a perl library and access it through library calls. But I don't want to be too confusing right now... As it seems, you don't need it at the moment.

In Reply To
What is AFAIK?

It's a popular term usually used in forums/newsgroups to save typing and means as far as I know. There are a lot more of these explained here. You seem to know as much of these hacker abbreviations as I know english idioms. Wink

Happy HTMLing and CGIing,
Marcus



JennyW
journeyman

May 30, 2001, 10:10 AM

Post #52 of 123 (6983 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Marcus! : )

In Reply To
Ok, now I know what you want. I've had a look at the source of the site you've linked to. It's the solution I thought of first when reading your last post, but then it occurred to me that it would behave exactly like it does on that page. But if you want it that way, perfect! Have you had a look at the source yet, or do you need some explanation?

Yes, I’ve had a look at the source. Actually, I have an example of that style of a Form at this link…
Just scroll to the bottom of the page. There should be a button that says, print msg. When you press it the word “message” displays.

http://jennyw.netfirms.com/form_test_05_29_01.html

I’ve tried to take the code for this form and put it in my Email sending Form (which is on the same page), but have been unsuccessful.

In Reply To
>>Well, if I ever decide to integrate my html within a .cgi document then can’t I just do all my html formatting in say, Dreamweaver and then cut and paste it into my .cgi document (Example… <<ENDHTML … ENDHTML)?
>That's usually the bad way, nevertheless it's a possible way. It's bad because it's nearly impossible to read the resulting mixture of HTML and Perl.

Do you mean it’s impossible for the .cgi program to produce results OR it’s just difficult to read as a programmer?

Thanks,
Jenny



mhx
Enthusiast / Moderator

May 30, 2001, 11:35 AM

Post #53 of 123 (6980 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hiho!


In Reply To
Yes, I’ve had a look at the source. Actually, I have an example of that style of a Form at this link
Just scroll to the bottom of the page. There should be a button that says, print msg. When you press it the word message displays.
http://jennyw.netfirms.com/form_test_05_29_01.html
I’ve tried to take the code for this form and put it in my Email sending Form (which is on the same page), but have been unsuccessful.

I'm not sure if you merged the code correctly. This is what you have (slightly compressed):

Code
<form ...> 
<input type="SUBMIT" value="Form Submission" name=SUBMIT style="...">
</form>
...
<form id=form1 name=form1>
<input type = "button" value = "print msg"
onclick = "msg.style.display = 'block'"
id=button1 name=button1>
</form>

This is on the dating page:

Code
<INPUT TYPE=BUTTON NAME=QuickSearchButton 
onclick="submit();disableQuickButtons();"
VALUE="Search Current Ads">

Try to replace the submit button in the first form on your page with the following code:

Code
<input type=button value="Form Submission" name=SUBMIT style="..." 
onclick="msg.style.display='block';submit();">

If you're lucky, it'll work and the text 'message' will disappear.
The submit(); function simulates a click on a submit button. It's important that this is contained in the onClick handler.

In Reply To
Do you mean it’s impossible for the .cgi program to produce results OR it’s just difficult to read as a programmer?

I mean it's difficult for the programmer. If you have to maintain software that has several 10,000 lines of code as I have to, you'll care a lot about readability. Crazy

Bye,
Marcus




JennyW
journeyman

May 30, 2001, 6:23 PM

Post #54 of 123 (6973 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus!

I still have a few problems.

I implemented the code, but now my “Submit Once! Form Validation” code isn’t working.

If you forgot what the Submit Once! Form Validation is…

http://

Here’s what I did…
red = new code. for pop up message.
purple = submit once form validation scripting.

<form action="cgi-bin/alphamail_new.cgi" method="POST" id=form1 name=form1 onSubmit="submitonce(this)">



<input type="button" value="Form Submission" name=SUBMIT style="background-color: #333333; color: #FFFFFF; font-family: Arial; font-size: 8pt; border-style: solid" onclick="msg.style.display='block';submit();">
</form>

<div id="msg" style = "display:none"><font color="#FFFFFF">Thank you!</font></div>

So, right now the words Thank You are displaying when Form Submission is selected. However, my Submit Once! Form Validation script isn’t working anymore.

What do you think could be the problem?

Thanks,
Jenny



mhx
Enthusiast / Moderator

May 30, 2001, 9:49 PM

Post #55 of 123 (6971 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

yeah, I've got another idea. (And I forgot what the Submit Once! Form Validation was...) Just put the old submit button back in, and add msg.style.display='block'; before submitonce() in the onSubmit handler. This will look like

Code
<form action="cgi-bin/alphamail_new.cgi" method="POST" 
onSubmit="msg.style.display='block';submitonce(this)">

BTW, I don't think id and name of the form are of any importance, so I took them out.
If this shouldn't work, well, I've got a bunch of other ideas, but I think it'll work this way.

Bye,
Marcus



JennyW
journeyman

May 31, 2001, 6:45 PM

Post #56 of 123 (6959 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus!

First, I just wanna stress how much I appreciate your help! I am serious, you have helped me so much and I just want to let you know that I really appreciate it.

Ok, I tried your code, but was unsuccessful. My Submit Once! Form Validation still won’t work, but everything else works great!

Here’s my new url…

http://jennyw.netfirms.com/form_test_05_31_01.html

Here’s what I adjusted…
Adjustments = purple

<form action="cgi-bin/alphamail_new.cgi" method="POST" onSubmit="msg.style.display='block'; "submitonce(this)">



<input type="SUBMIT" value="Form Submission" name=SUBMIT style="background-color: #333333; color: #FFFFFF; font-family: Arial; font-size: 8pt; border-style: solid" onclick="msg.style.display='block';submit();">
</form>

<div id="msg" style = "display:none"><font color="#FFFFFF">Thank you!</font>
</div>

Do you have any other ideas as to what I could adjust?

In Reply To
BTW, I don't think id and name of the form are of any importance, so I took them out.
If this shouldn't work, well, I've got a bunch of other ideas, but I think it'll work this way.

Why are id and name not necessary?

Thanks again Marcus.
Jenny



mhx
Enthusiast / Moderator

May 31, 2001, 11:53 PM

Post #57 of 123 (6956 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

Good message: I can tell you why it didn't work! Smile
Bad message: It's only that you made a typo... Shocked

If you compare what I posted and what you put in the code, you'll notice an additional double quote:

Code
onSubmit="msg.style.display='block'; "submitonce(this)"

Since the HTML parser only uses the text surrounded by double quotes for onSubmit, it doesn't call the submitonce() function with your code. In fact, this is actually an HTML error, but today's browser are very failsoft, which is not always an advantage.
(Just to avoid confusion on the double quote thing: The parser first recognizes onSubmit=, then scans the first quoting character. This may be either a single or a double quote. Now, it simply searches for the next occurrence of that quote character, and treats the text in between as code to call when someone hits the Submit button.)
So, the solution is simple, just remove the red double quote from the onSubmit expression.

In Reply To
Why are id and name not necessary?

They are only neccessary if you want to access the form by its name or id, which you never do in your page. Every tag inside the form knows implicitly to which form it belongs, the form itself keeps track of which cgi script to call, and the only function that could use the name of the form is the submitonce() function, but you pass this as a parameter, which is a placeholder for the current object (in this case, the form), so the submitonce function also knows about your form. No need to name it. Wink

Since I wanted to be sure it'll work now I've tested the page locally on my machine. Without the quote it works, what shall I say, great! Have fun trying!

Bye,
Marcus



JennyW
journeyman

Jun 1, 2001, 5:33 PM

Post #58 of 123 (6946 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hiee!

It’s great! It works! Thanks!!!

In Reply To
Since I wanted to be sure it'll work now I've tested the page locally on my machine

Here’s my url..
Jenny’s almost complete email Form

What do you mean when you write locally?
Do you mean you have your own server, like Apache on your computer?


I’m gonna have more questions for you very soon.

Thanks again,
Jenny



mhx
Enthusiast / Moderator

Jun 1, 2001, 11:41 PM

Post #59 of 123 (6942 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

In Reply To
What do you mean when you write locally?
Do you mean you have your own server, like Apache on your computer?

Yes. (That's a simple one...)

In Reply To
I’m gonna have more questions for you very soon.

I can't await to answer them. SmileCoolWink

Bye,
Marcus




JennyW
journeyman

Jun 2, 2001, 11:50 AM

Post #60 of 123 (6931 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus! How’s the weekend going?

When you receive an auto-reply from my Form my name comes up like this in the recipients inbox:


Code
themustache@hotmail....

I don’t like that. I want it to come up like this…


Code
Jenny W

So, I attempted to solve the problem.
I went in my .cgi script with the

Code
sub SendAutoReply {

and made an adjustment.

Here’s what was in my final .cgi script, which you helped me edit…


Code
print MAIL "From: $YourEmail\n";

And I changed it to the following…


Code
print MAIL "From: Jenny W\n";

Now, my Form still works, but if someone selects auto-reply, my email name will look like this in their inbox


Code
Jenny.W@netfirms.com

I don’t want it to look like that. I just want…


Code
Jenny W



Do you know how I can fix this problem?

Thanks,
Jenny



mhx
Enthusiast / Moderator

Jun 2, 2001, 1:59 PM

Post #61 of 123 (6928 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,


In Reply To
How’s the weekend going?

Fine, thanks. Just came back home from playing pool with, well, Jenny. (Not you actually...)

In Reply To
Do you know how I can fix this problem?

Yes, that's pretty easy. Don't change your SendAutoReply function, undo the changes you made. Go a bit to the top, where $YourEmail is defined and change it to:

Code
$YourEmail = 'Jenny W <themustache@hotmail.com>';

This will make your name appear in (most) mail programs instead of your address, but will leave the opportunity to the receiver to reply to the address. If you don't want this, I guess you'll have to get a dummy account somewhere. At least I don't know how to get around this, since I'm not sendmail expert...

Hope your weekend is as fine as mine,

Marcus




JennyW
journeyman

Jun 2, 2001, 2:48 PM

Post #62 of 123 (6928 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus,

My weekend is good so far. I’m spending a ‘lil too much time on the computer, but soon I’m gonna get off for a bit.

I made the $YourEmail change you mentioned and it worked perfectly. Thank you.

Here’s the url for my Form page.

I’m gonna go dive into another area of .cgi.

I want to make a poll on a page that changes dynamically.

For example:
I want the user to place a vote and then I want that same page to refresh showing the current poll statistics.

I've been looking for some Perl scripts that can do this, but all the scripts I’ve seen have the user place a vote and then be brought to a new page to view the results.
I don’t like this. After the user votes I want the results to be placed exactly where the voting was done.

Do you know a place where I can get a simple script that does this?

If you’re unsure it’s totally fine, I’m sure I’ll eventually find one!

Thanks,
Jenny

P.S. You should play pool with this Jenny – I’m not the best, but I do ok!



mhx
Enthusiast / Moderator

Jun 3, 2001, 10:57 AM

Post #63 of 123 (6923 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,


In Reply To
I’m spending a ‘lil too much time on the computer,

Really? Smile


In Reply To
Do you know a place where I can get a simple script that does this?

I've been thinking about a voting script for my DVD page. I've also done some coding, but I was far from being finished. I took what I had and modified it a bit so - as I hope - it could fit your needs.
It's a very universal script, capable of managing as many polls as you like. You can take a first look at how it looks here.
You don't have to change anything on the script itself, since it is configured by some external files. You need one file called votes.txt, which lists all the polls you like to offer. It looks like this:

Code
[likeperl] 
title = Do you like Perl?
file = likeperl.txt
date = 2001-05-31 13:10:00
state = active

[htmltag]
title = Which is the HTML tag you like most?
file = htmltag.txt
date = 2000-04-30
state = active

[whereisit]
title = Tell us where your Perl is!
file = whereisit.txt
date = 2001-01-01
state = closed

You also need one file for each poll where the voting items and the results are stored. These look like this one:

Code
Perl rules! [34] 
Yeah, I do like Perl! [13]
Ahh, well, Python is fine, too. [4]
Perl sucks! [3]
What the hell is this Perl? [8]

First, let's have a look at the first file. Each poll starts with the Poll ID enclosed in square brackets. This would be likeperl for the first entry. Each of the lines following the Poll ID contains description of the poll.
title is the poll's title.
file is the file where the voting items and results are stored.
date holds the date when the poll was introduced. This is currently only used for sorting the polls from new to old.
state is the state of the poll, which can only be active or closed. You cannot vote for a closed poll.
Now, the other file simply contains one line for each voting item, with the number of votes for this item in square brackets at the end of the line. This file is modified each time a user places a vote.
All you have to do to add a new poll is to add an entry in the votes.txt and add a file containing the voting items, each line ending with [0].
I've put a copy of my cgi-bin directory into my www directory, so you can download all the files. You can browse through these files here.
You'll have to download all the files. The .txt files contain the information listed above. vote.cgi is the cgi-script. voteutil.pm contains utility routines for the script.
The subdirectories Date and Time each contain additional files required by the script. You also have to download these files and put them in exactly the same directories in your cgi-bin.
There are two ways to refer to the script. If you want the list, just refer to the script's URL, which is

Code
cgi-bin/vote.cgi

You can also go directly to a poll by using this URL,

Code
cgi-bin/vote.cgi?vote=likeperl

where I've put likeperl as a placeholder for any Poll ID.
I hope you understand all that I've written here, at least after looking at the files and playing with the script. If you don't understand everything, I don't mind if you ask for details. If you have suggestions, you're also welcome. The script is everything but perfect, I think, because it was hacked in only a few hours. For example I have to look over the files because I always mix up poll and vote. Oooo my english!! I just wanted to poll first if you're interested in the script.

Bye,
Marcus

P.S.:

In Reply To
You should play pool with this Jenny - I’m not the best, but I do ok!

I only play twice a month, so I'm not the best either. Wink



JennyW
journeyman

Jun 4, 2001, 8:52 AM

Post #64 of 123 (6913 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus!

Thanks for all the info on your Poll script.

Before I get into polls, I just found a few old questions I wanted to ask you regarding my email Form.

There are three fields on my Form…

Name
Email
Message

All of the fields HAVE to be filled out in order to send the Form. I don’t like that feature. I don’t think the Name field should be required.

How do I make the Name field optional?

Also,
In the future I want to make a mailing list.
To sign up for the mailing list I only need an Email field.

I want to make another .cgi script that ONLY accepts email addresses (no Name or Message). How can I adjust the .cgi code you helped me with to make it only look for valid Email addresses?

Polls

Your website’s poll is really good, but unfortunately I’m not really looking for that kind of poll.
I’m looking for a poll similar to the url listed below (after clicking on the link scroll to the bottom right hand corner of the page).

Basically, the user makes a selection on the poll using radio buttons. After my submitting the selection the page refreshes the results are placed in the exact location of where the voting took place.

Here’s the poll I like…

nfl

I found a site that offers a similar poll to the one listed above. Poll

Thanks,
Jenny



mhx
Enthusiast / Moderator

Jun 4, 2001, 3:01 PM

Post #65 of 123 (6908 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

sorry, I got little time at the moment, because I prepare a lecture on wavelets in medical applications which I'm about to do in two days. Quite some work...
But here's what I have:

In Reply To
How do I make the Name field optional?

That's easy. Just find the following line and comment it out, and the script should work even without a name.

Code
if (!$Name || $Name eq ' ') {&DoEmailError;}

But, you could even make it better and instead of the above write:

Code
if (!$Name || $Name eq ' ') {$Name = 'Anonymous';}

So if one doesn't enter a name, the script will automagically assign the name 'Anonymous'. This is better, because $Name is used in some places, and this way it is never left empty.

In Reply To
How can I adjust the .cgi code you helped me with to make it only look for valid Email addresses?

I'd say if you want to set up a mailing list, you should definitely use another script. If you want to check the validity of an email address, here's the URL to go to. It contains links to different versions of a perl script that check if an email address is valid. But beware, it's hardcore regex in Perl.
Concerning the poll stuff, I couldn't really figure out the differences (in general) between the polls. Except for the fact that I was unable to vote on the NFL page. (Which isn't so bad since I know absolutely nothing about football...) I guess you mean the presentation of the poll. Of course, you can take my code as a basis and modify it for your needs. Or you can just search for another resource.
So much for now, hope the little I've posted was of any help.

Bye,
Marcus



JennyW
journeyman

Jun 4, 2001, 5:40 PM

Post #66 of 123 (6905 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus!

In Reply To

Code
 if (!$Name || $Name eq ' ') {$Name = 'Anonymous';}


Thanks! That piece of script worked great! I’m assuming that if I decide I don’t even want the word “Anonymous” to display then I just have to comment out the line above?

In Reply To
So if one doesn't enter a name, the script will automagically assign the name 'Anonymous'. This is better, because $Name is used in some places, and this way it is never left empty.


What does the segment in blue mean? $Name is used in some places?

In Reply To
sorry, I got little time at the moment, because I prepare a lecture on wavelets in medical applications which I'm about to do in two days. Quite some work...

Wow, that’s great! Good-luck with that presentation! You probably don’t need luck, but I’ll send it your way anyhow. Regardless, I’ll keep my questions to a minimum for the next few days!

In Reply To
But beware, it's hardcore regex in Perl.

What does that mean?

In Reply To
Concerning the poll stuff, I couldn't really figure out the differences (in general) between the polls. Except for the fact that I was unable to vote on the NFL page. (Which isn't so bad since I know absolutely nothing about football...) I guess you mean the presentation of the poll. Of course, you can take my code as a basis and modify it for your needs. Or you can just search for another resource.
So much for now, hope the little I've posted was of any help.

Of course! What was I thinking? Ahhh. Yes, I would love to use your code!

If I use your code is it possible for the poll to have the users select a radio button and then press a submit button to send their vote?

Were you unable to vote on the nfl poll because you don’t know anything about football or was the poll broken?

Thanks,
Jenny



mhx
Enthusiast / Moderator

Jun 4, 2001, 11:44 PM

Post #67 of 123 (6901 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

it seems it was a bit late when I was answering yesterday. Smile Well I'll try to be more precise this time.
Concerning the anonymous thing your assumption is right.

In Reply To
What does the segment in blue mean? $Name is used in some places?

As I said, it was late and I didn't find the right words. I meant that the variable $Name is used to insert the name of the form user in the text for both the mail to you and the autoreply mail. If the user doesn't enter a name, nothing is inserted in both mails. It's a matter of taste what solution you choose. So don't hesitate to comment the line out.

In Reply To
Good-luck with that presentation!

Thanks a lot. Reminds me that I gotta get myself working now...

In Reply To
What does that mean?

You know Regular Expressions? Short term for them is regex. A regular expression is used for an abstract description of some part of a text, e.g. an email address. Regular expressions, even short ones, look quite weird to the beginner. And the email checking regex looks even weird to the perl guru (although he may at least be able to recognize it's a regex Wink). To give you a little impression, here's the fast version of the email validation regex (please, don't try to understand and don't ask me to explain):

Code
[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\ 
xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(
\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[\04
0\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\
n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\
xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]
*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n
\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\(
[^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*@[
\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\x
ff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040
)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\x
ff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x8
0-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\
n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:"
.\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x8
0-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xf
f][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*|(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-
\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\01
5"]*)*")[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037]*(?:(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([
^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)|"[^\\\x80-\xff\
n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037]*)*<[\040\t]*
(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015
()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:@[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\
([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:
[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\0
15\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*
(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80
-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\
\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\
037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[
^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[
\040\t]*)*)*(?:,[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80
-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*@[\040\t]*(?:\([^\\\x80-\xff\n\015()]*
(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015
()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|
\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([
^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.
[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\
xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\04
0)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\
xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x
80-\xff\n\015()]*)*\)[\040\t]*)*)*)*:[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff
\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)?(?:[^(\040)<>@,
;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80
-\xff][^\\\x80-\xff\n\015"]*)*")[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\01
5()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\
\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\)
)[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\
000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[\040\t]*(?:\([^\\\x80-\
xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x
80-\xff\n\015()]*)*\)[\040\t]*)*)*@[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n
\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".
\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80
-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff
][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(
?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015(
)]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\
[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^
\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*>)

Of course you may ask me about regular expressions, I really, really like them, but this monster above is not what I use everyday.

In Reply To
If I use your code is it possible for the poll to have the users select a radio button and then press a submit button to send their vote?

I guess that should be no problem. If you can wait for another 48 hours, I can check this out. You can also have a try yourself, the code shoud be readable as long as you have some Perl experience.

In Reply To
Were you unable to vote on the nfl poll because you don’t know anything about football or was the poll broken?

No, having nothing to do with football couldn't have stopped me from voting. I just didn't find a submit button or at least any button to click on. Perhaps they closed the poll...

Bye,
Marcus



JennyW
journeyman

Jun 5, 2001, 7:54 PM

Post #68 of 123 (6896 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus,

I’ll try to keep this straight and simple since you’re busy busy!

I have to go back to my email Form again.

I want the email address field to be optional, but if someone does enter an email address (most will) I still want the .cgi program to decipher if the entered email address is valid.

Do I do something with the following line?


Code
if (!$Email || $Email eq ' ') {&DoEmailError;}


In Reply To
>>If I use your code is it possible for the poll to have the users select a radio button and then press a submit button to send their vote?
>I guess that should be no problem. If you can wait for another 48 hours, I can check this out.

I’ll try to play around with it, but whenever you get the time I’d appreciate any help you could offer.

I also tried your poll. Its functionality was good, but the only thing I didn’t like was that I could make several votes after my initial (first) vote.

Is it possible for the poll to track the users IP address so he/she can only vote once?

And if you have the time - what is a regular expression?


Thanks,
Jenny

P.S. Goodluck with the presentation!



mhx
Enthusiast / Moderator

Jun 6, 2001, 3:38 AM

Post #69 of 123 (6890 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

In Reply To
I want the email address field to be optional, but if someone does enter an email address (most will) I still want the .cgi program to decipher if the entered email address is valid.

I'll have a look tonight. I think it's a bit more difficult, since you also have to check for the autoreply message to be sent. If someone doesn't enter an address, you can't send him a reply. (I think... Smile) But it should be no problem in general.

In Reply To
Is it possible for the poll to track the users IP address so he/she can only vote once?

Yeah, I think that's possible. It's something I'm also thinking about, and I wish I had the perfect solution. The problem is, most users will not have a static IP address. So each time they dial up to their provider, they may be assigned a new address. Even worse, someone else may get the IP address of someone who already voted. The solution I have in mind right now (it's not yet implemented) is the following. I'll keep track of the IP addresses of the voter and block this address for a certain time, let's say 1-5 minutes. I'm also considering to use a cookie, since then I can be sure that the infomation is on the user's machine. But I need the other approach if the user has turned of cookies. I'm not so sure what I'll do here, but you can be sure that I'll do something, and I'll tell you if I got a solution.

In Reply To
And if you have the time - what is a regular expression?

I'll tell you next time. Just take this as a preface: It one of the coolest features Perl has to offer. There's four things in Perl that make it my favourite language, and that make programming in Perl real fun: regular expressions, hash tables, map & grep. You can do just about anything with these features. I'll tell you more about regexes and perhaps the other things if I'm not dying tonite!

Bye,
Marcus


In Reply To
P.S. Goodluck with the presentation!

Thanks again, in about 6 hours it'll be over...




JennyW
journeyman

Jun 6, 2001, 6:42 AM

Post #70 of 123 (6889 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus! How was the presentation!

In Reply To
>>Is it possible for the poll to track the users IP address so he/she can only vote once?

>Yeah, I think that's possible. It's something I'm also thinking about, and I wish I had the perfect solution. The problem is, most users will not have a static IP address. So each time they dial up to their provider, they may be assigned a new address. Even worse, someone else may get the IP address of someone who already voted.

You bring up some very solid points. You reminded me that my IP address changes each time I log on.

In Reply To
The solution I have in mind right now (it's not yet implemented) is the following. I'll keep track of the IP addresses of the voter and block this address for a certain time, let's say 1-5 minutes. I'm also considering to use a cookie, since then I can be sure that the infomation is on the user's machine. But I need the other approach if the user has turned of cookies. I'm not so sure what I'll do here, but you can be sure that I'll do something, and I'll tell you if I got a solution.

It sounds like you have a few great ideas!

What would happen if I took your .cgi poll script and adjusted it for my index.html page?
Can I put it on my index.html page?


Thanky,
Jenny



mhx
Enthusiast / Moderator

Jun 6, 2001, 1:51 PM

Post #71 of 123 (6882 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,


In Reply To
How was the presentation!

It was just fine, thanks. People were asking lots of questions, which shows to me they were interested and they captured a lot of what I was talking about. At least my parents now know something about Wavelets, X-Ray image compression and ECG signal analysisWink.

In Reply To
What would happen if I took your .cgi poll script and adjusted it for my index.html page?
Can I put it on my index.html page?

Depends on what you want to do. Do you want the poll to appear as a part of your page? I haven't thought of that yet, because the output of the script is quite huge and occupies most of the screen. If you want to link to a poll, just look at my initial poll-related post.
If you prefer to have it as part of your page, well, I guess I'll have to take care of this next time I'm working on the script...
Now, your optional email field. I'm not sure what sendmail will do without a sender email address. I guess it'll insert something. Nevertheless, you should take care of it and enter some dummy address if the user doesn't. Here's the solution I'd recommend: Remove the line

Code
&CheckEmailAddressFormat;

and replace

Code
&SendSubmission; 
&SendAutoReply if exists $in{'WantAutoReply'};

with

Code
if( $Email =~ /^\s*$/ ) { 
$Email = 'dummy@email.com';
&SendSubmission;
}
else {
&CheckEmailAddressFormat;
&SendSubmission;
&SendAutoReply if exists $in{'WantAutoReply'};
}

I guess that should make it work, but I haven't tested it.
But now ... let's go for a short intro on regular expressions. I've just used a regular expression in the above code, and after this, you should be able to understand it.
In short, a regular expression is an abstract description for a set of strings (hope you don't find this too mathematic). You can use regular expressions to check if a string matches certain criteria, or for searching and replacing.
Ahh, I'm telling too much abstract stuff. Here's an example. Let's say you want to test if a string starts with an uppercase 'A'. Use this code:

Code
$string = 'Ahh, yeah!'; 
if( $string =~ /^A/ ) {
...
}

The green thing is the regular expression match operator. Just read it as 'matches'. The red stuff surrounded by slashes is the regular expression. Yes, it's only two characters, and these are easy to explain.
The circumflex is an anchor for the beginning of the string. The 'A' is just the uppercase letter A. You can read the above line: 'if $string matches a string containing the beginning of the string followed by an uppercase A'. This is, of course, true for our string.
If you wouldn't use the circumflex, it would read 'if $string matches a string containing an uppercase A', and this would be true for any string that contains an 'A' anywhere. Now, let's move on to something more complicated:

Code
$string = '12 cm'; 
if( $string =~ /^\d+\s*cm$/ )

That looks weird? It's easy. The '\d' simply means 'any digit', the '+' means 'one or more of the previous', the '\s' means 'any blank character' (spaces, tabs), the '*' means 'zero or more of the previous', and finally the dollar sign is an anchor for the end of the string.
To convert the regex to normal language: 'a string containing the beginning of the string followed by one or more digits followed by zero or more blanks followed by cm followed by the end of the string'. This, again, is absolutely true.
Now, that's only a very, very brief example of what you can do with regular expressions. You can do a great lot more than just this. I have a 300 page book covering nothing but regular expression. It's one of the best books I have actually ('Mastering Regular Expressions' by Jeffrey Friedl, published by O'Reilly).
With what you now know, you should be able to detect the regex in the above code and determine what it does. You should also see why a regex makes sense here. (I'll await your opinion on this)
If you're more interested in regular expression, you should have a look at 'perldoc perlre', or just ask me, or have a look at the 'Regular expressions' section in this forum. But I think what you really need first is good introduction on Perl, just to get the basics. CGI programming will be a lot easier then.
There's a really, really good tutorial on Perl for Windows. I read when I started with Perl and it really helped me getting into it. You should absolutely read it. It's here.
If you got this, you're ready to learn more about Perl's advanced features.
I hope you'll have as much fun reading the tutorial as I had. If you have problems or questions, don't hesitate to ask.

Bye,
Marcus



JennyW
journeyman

Jun 6, 2001, 6:25 PM

Post #72 of 123 (6881 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus! Glad to hear your presentation went well!

You got me thinking and I don’t think I’m going to keep the email address on my Form mandatory. You brought up some very important issues in your email yesterday, which really got me thinking.

Wow! Right now regular expressions are a little hard! In time perhaps. However, you explained regular expressions quite well and I’m glad I’m now equipped with the basic info. of understanding their function!

- A .cgi script that just accepts Email Addresses (mailing list) –

In Reply To
I'd say if you want to set up a mailing list, you should definitely use another script. If you want to check the validity of an email address, here's the URL to go to. It contains links to different versions of a perl script that check if an email address is valid. But beware, it's hardcore regex in Perl.

When you write beware do you mean that the script could be faulty? Or do you mean it will be difficult to understand?

I went to that url you mentioned above, but I’m not sure which script to download.

The page writes…

In Reply To
At the moment, I have only the email address regex program (from Chapter 7 and Appendix B), as it's the most substantive bit of code.
There is an optimized version from Appendix A and the unoptimized version discussed in Chapter 7.

DOS users may find these versions (optimized and unoptimized) easier to download -- the Perl is the same, but the lines end with CR/LF, and the URLs endi with ``.txt''.


What do I download? I’m a little confused.

- Polls -

In Reply To
>>What would happen if I took your .cgi poll script and adjusted it for my index.html page?
Can I put it on my index.html page?
>Depends on what you want to do. Do you want the poll to appear as a part of your page?

Yes. I want the poll to be in the bottom corner of my index.html page. After people vote on the poll and press submit I want the index.html page to refresh and display the results in the place the voting once took place.
I think this script does just that…

http://www.cgi-world.com/pollit.html

Is there anything else I wanted to ask you? Hmmm, can’t think of anything right now, but you can bet I’ll keep the questions coming soon!

Thanks so much Marcus!
Jenny



mhx
Enthusiast / Moderator

Jun 6, 2001, 10:34 PM

Post #73 of 123 (6877 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,


In Reply To
You got me thinking ...

That's always a good thing. I really like it if I get people thinking. Because that's when they learn most!

In Reply To
When you write beware do you mean that the script could be faulty? Or do you mean it will be difficult to understand?
...
What do I download?

Oooo, I've got to clear this up. First, when I said beware I meant that it's really hard to understand. I absolutely don't think they're faulty, because they're from the same person that wrote the huge book about regexes.
Second, that script (it isn't really a script) does nothing but checking if an email address is valid. You've got to take it, encapsulate it in a subroutine, and use it in a script for mailing lists (which you still have to figure out).
You shouldn't download the DOS version. The other two version do the same, except one is optimized and one isn't. I'd take the optimized version.
Concerning the poll, I think putting it 'in the bottom corner' is quite hard with my poll because of its size. But, well, let's see what I'll do with the script, perhaps I'll add a 'small' option to it. Smile
Here's again something you can do for me: I always try to improve my language skills (not only programming languages). You may have noticed that I use 'concerning this and that, bla bla' (as in the last paragraph) quite often. It's from my english lessons. I really liked it but I've never seen or heard anyone else using it. What I'd really like to know: Does anyone use this? Or is it just that my english teacher used it all the time? Or is there a similar expression that is more commonly used? Thanks!

Bye,
Marcus



JennyW
journeyman

Jun 7, 2001, 7:09 AM

Post #74 of 123 (6875 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hiee!!


In Reply To
Second, that script (it isn't really a script) does nothing but checking if an email address is valid. You've got to take it, encapsulate it in a subroutine, and use it in a script for mailing lists (which you still have to figure out).

What does the part in red mean?

Why can’t I just find a script that just parses email addresses? Why do I need that regex? We didn’t need one when adjusting the email Form.


In Reply To
I'd take the optimized version.

Out of curiosity, why would you take the optimized version versus the unoptomized version?

In Reply To
Concerning the poll, I think putting it 'in the bottom corner' is quite hard with my poll because of its size. But, well, let's see what I'll do with the script, perhaps I'll add a 'small' option to it.

Can this be solved by just adjusting the Form layout in the html?


In Reply To
Here's again something you can do for me: I always try to improve my language skills (not only programming languages). You may have noticed that I use 'concerning this and that, bla bla' (as in the last paragraph) quite often. It's from my english lessons. I really liked it but I've never seen or heard anyone else using it. What I'd really like to know: Does anyone use this?

Yes, people use concerning this / that. You know how I can tell it sounds fine? Because when I read it, I don’t think anything of it. It sounds very normal.

In Reply To
Or is it just that my english teacher used it all the time? Or is there a similar expression that is more commonly used?

Concerning this / that is fine.
You can use lots of other words (or word combinations), like in regards to, regarding this / that, on the subject of, on the topic of, about this / that.
But to tell you the truth I never noticed that you used concerning a lot. If you never told me you were from Germany then I would assume you were from an english country – strictly because your writing is good. The more you verbally speak to english people (or any language) the more you’ll pick up different ways of saying things. You’re doing great! How long have you known the english language?

Thanks,
Jenny



mhx
Enthusiast / Moderator

Jun 7, 2001, 12:00 PM

Post #75 of 123 (6869 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi!


In Reply To
What does the part in red mean?
Why can’t I just find a script that just parses email addresses? Why do I need that regex? We didn’t need one when adjusting the email Form.

Did I say you need the regex? Sorry. You can use it, but actually it's optional. The regex is only needed if you want to be absolutely sure that an email address is a valid email address (except, of course, the regex cannot check if it exists).
With encapsulation in a subroutine I was trying to say that the regex stuff should be moved into a subroutine, so you can use a subroutine call to verify an email address.
Fortunately, you don't have to do this. I figured out someone else has just done it and made a Perl module out of the regex. It's called Email::Valid and is available from CPAN if it should not be installed locally or at netfirms. Usage is very simple:

Code
use Email::Valid; 

my $email = 'mhx@gmx.de';

if( Email::Valid->address( $email ) ) {
print "$email is a valid email address!\n";
}
else {
print "$email is invalid!\n";
}

The red part makes the module available to the script, the green part is used to check the address.

In Reply To
Out of curiosity, why would you take the optimized version versus the unoptomized version?

Because it's optimized (?!) What do you want to hear? I assume the optimized version is faster, therefore I'd prefer it.

In Reply To
Can this be solved by just adjusting the Form layout in the html?

Yes and no. Yes you can adjust the layout of the table I'm using. No, because there's no html. There's another problem that I see right now. If you want to use the poll within another page, you need to either create that whole page dynamically (because its content - the poll results - is dynamic) or embed the poll within a frame, which can be a problem at netfirms (I'm not sure why, but I had difficulties displaying a page that had frames). Did you have a look at the script yet?

In Reply To
How long have you known the english language?

Thanks for the detailed information on my language issue! It just came to my mind as I wrote that I use the expression quite often, and I couldn't think of any replacement just then. Now that I see your examples, they all sound clear and good, perhaps I'll remember some of them and use them from time to time.
To answer your question, I've had english lessons at school for nine years. But I was driving most of my teachers crazy because I was never interested in the topics we were discussing. Unfortunately - for them - I was quite good in the syntax and semantics of the language (which perhaps is because I'm a programmer Smile), so they couldn't give me a bad grade.
I've finished school five years ago and since then, all my english is from TV and www (and reading docs and articles only available in english). And since most programming languages are derived from the english language, it's often easier to write comments in english, too. For me it's easier to write documentation for software I'm working on in english than in german.

Bye,
Marcus



JennyW
journeyman

Jun 8, 2001, 7:31 PM

Post #76 of 123 (6690 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Sparkus Marus!

In Reply To
Fortunately, you don't have to do this. I figured out someone else has just done it and made a Perl module out of the regex. It's called Email::Valid and is available from CPAN if it should not be installed locally or at netfirms. Usage is very simple:

use Email::Valid;

my $email = 'mhx@gmx.de';

if( Email::Valid->address( $email ) ) {
print "$email is a valid email address!\n";
}
else {
print "$email is invalid!\n";
}
The red part makes the module available to the script, the green part is used to check the address.

So, you’re saying instead of that regex I can use the above to verify email addresses?

In Reply To
>>Out of curiosity, why would you take the optimized version versus the unoptomized version?

>Because it's optimized (?!) What do you want to hear? I assume the optimized version is faster, therefore I'd prefer it.

You’ll have to bare with me. I’m not too versed with some internet language. What does optimized mean versus unoptimzed? Why is optimized faster?

I have to figure out what I want to learn first: polls or a mailing list? And right now accepting email addresses for a mailing list is higher priority for me than learning polls.

I’m want to learn more about polls after I figure how to make a mailing list. If I do two things at once (mailing list and polls) I’ll confuse myself.

I’m gonna start looking for a mailing list script that suits my needs. Like usual I’ll ask you for your help when I come across a problem.

I want to be able to send HUGE amounts of emails when I have my mailing list set up. Do you have any suggestions as to what kind of mailing list script I should be looking for?

Thanks,
Jenny



mhx
Enthusiast / Moderator

Jun 9, 2001, 12:06 AM

Post #77 of 123 (6684 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,


In Reply To
So, you’re saying instead of that regex I can use the above to verify email addresses?

Oui, c'est que je dit. (I'm just sitting at home watching a Cranberries concert in Paris. I'll leave the french now...)
You can use the code I provided instead of the regex, because Email::Valid contains that regex. So you don't have to care about how to use it.

In Reply To
You’ll have to bare with me. I’m not too versed with some internet language. What does optimized mean versus unoptimzed? Why is optimized faster?

I'm sorry, I thought a term like optimized would be self-explaining in any language. It's not from internet language in this context, but from programming language. Code development mostly works like this: You start searching for or inventing an algorithm and write a very simple version of it. Then you check if it works. Because it's simple, you can easily fix any bugs (errors are called bugs). If you got the algorithm working, you normally do some benchmarking. This means you check how long it takes for the algorithm to perform its task and how much memory is consumed. If you find that its performance is very poor or not good enough for you, you normally consider to optimize your simple (or basic or unoptimized) algorithm. This means you search for parts of the code that aren't very efficient and replace them by equivalent code that seems more efficient to you. The problem is that efficient code is often significantly longer and more complicated than the basic version of it. So your basic code becomes faster or uses less memory when you optimize it. I hope I explained this without using too much terms unknown to you...

In Reply To
I want to be able to send HUGE amounts of emails when I have my mailing list set up. Do you have any suggestions as to what kind of mailing list script I should be looking for?

If you really want to set up a huge mailing list (which is quite close to the forum you're currently in, just without the forum), there are special server software called majordomo. It's written in Perl, but I don't think it's intended to be used as cgi-script, so you won't be able to use it on netfirms. But, there is a list of internet mailing list provider available. These allow you to create and maintain your own mailing list(s). Since I haven't done anything with mailing lists yet, I cannot really help you in choosing one of them (if you want to). Right now, I'm not sure if you want a mailing list, because a mailing list is relatively independent from your website. The purpose of a mailing list - in brief - is to manage that incomimg mails (sent by anyone who's on the list) are sent to everyone else on the list but the sender itself (except he wants to receive copies). I hope this makes clear what a mailing list is and helps you to decide whether what you want is a mailing list or not.

Bye,
Marcus



JennyW
journeyman

Jun 9, 2001, 10:24 AM

Post #78 of 123 (6680 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus!! Saturday is here!

Thanks for the explanation on optimization. I read it through a couple times and it seems to be somewhat sinking in (sinking in means I’m beginning to understand it!!


In Reply To
The purpose of a mailing list - in brief - is to manage that incomimg mails (sent by anyone who's on the list) are sent to everyone else on the list but the sender itself (except he wants to receive copies). I hope this makes clear what a mailing list is and helps you to decide whether what you want is a mailing list or not.

Thank heavens you explained that too me. I would have wasted a good hour looking for a mailing list script. I guess I’m not looking for a mailing list.

What I’m looking for is something similar to my email Form. I want people to ONLY send me their email address so I can add them to a list. Then I want to email that list once a month to tell them about updates on my website.

Thanks for the explanation!
Jenny



alex
stranger

Jun 9, 2001, 10:28 AM

Post #79 of 123 (6680 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Wow. That took ages to read. Interesting tho :)



freddo
User

Jun 10, 2001, 12:57 PM

Post #80 of 123 (6670 views)
my two cents [In reply to] Can't Post

Hello,

when there's that much different problems in a question, wouldnt it be smarter to post it in, smaller, different questions (posts), with a revealing subject?

it's hard to understand all the follow ups when you read them since replies appears in the date of the post order.

dont want to bother, it's just my two cents,
freddo

;---
ygjohn: sometimes. you talk too much.. hahaha..


JennyW
journeyman

Jun 10, 2001, 3:34 PM

Post #81 of 123 (6665 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus,

Well, I found a script(s) that I can use! But like normal I’m having a few problems. The good thing is you helped me sooo well with the last email Form that I used a lot of that knowledge when making slight adjustments to this new script!

http://maillist.pl and mail-admin.pl

In Reply To

2) Open cfg.pl with a text editor than modify the variables.

I used notepad and made my modifications to cfg.pl.

The only error I could have made in this file was with on the sendmail line. I changed the location of sendmail to /usr/lib/sendmail, which is correct. The original script had sendmail in a different location and they also had a -t"; after the sendmail line. Could the problem be that I kept the -t"; ?

In Reply To
3) Upload the scripts to your cgi-bin then chmod them to "755."

I uploaded maillist.pl and mail-admin.pl and cfg.pl to the .cgi-bin at netfirms. I gave each file chmod of 755. I have read, write, execute permission to the OWNER. I gave read and execute permissions to GROUP AND OTHER.

In Reply To
4) Modify the header and footer files with a text editor.
header.txt and footer.txt will go in the email message.
dheader.txt and dfooter.txt will be used when a visitor's email address has been added or removed.

I don’t think I can make errors on these files, they were very very very basic. But here they are… header.txt, footer.txt, dheader.txt, dfooter.txt

In Reply To
5) Upload header.txt, footer.txt, dheader.txt, and dfooter.txt to the same directory where you uploaded the scripts.
Then chmod them to "777."

I uploaded the scripts above to the my .cgi-bin. I gave them all chmod 777, which gives the owner, group and other read, write and execute permissions.

In Reply To
6) Upload pass.dat, list.txt, and errorlog.txt, to the same directory where you uploaded the scripts.
Then chmod them to "777."

I uploaded the .txt files and .dat file above with the same permissions as I wrote for #5 (above). The list.txt file is empty right now. That’s where the email addresses will be stored when people send me their email address.

I don’t really know what I can do with the errorlog.txt file. I uploaded it, but how can I view it so it can help me?

In Reply To
7) Execute the admin script (mail-admin.pl) with your browser (Point to url to main-admin.pl).
The script will ask you to set up your admin password.

I called the main-admin.pl script by typing the url…
<A target="_blank" HREF=http://jennyw2.netfirms.com/cgi-bin/mail-admin.pl.

I entered my password and the received this message…

An error has been occured. The error is: Unable to open the data file for reading
Reason: No such file or directory


What does that mean? Which file do you think they’re talking about?

In Reply To
8) copy and paste the tags below then paste them on your html document.

Here’s the url where the user can send me their email address: http://jennyw2.netfirms.com/mailing_list.htm

In Reply To
9) Done.

!!Important!!
All of the script files and data files have to be uploaded in "ASCII" mode or you will always get a 500 server error while accessing the program.

I did this. I would never forget this step!

What do you think the problem could be?

Thanks for taking the time to read all this.
Jenny



JennyW
journeyman

Jun 10, 2001, 6:21 PM

Post #82 of 123 (6662 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Marcus WAIT! WAIT!

Disregard a lot of the above. I figured out how to send bulk emails. I got the .cgi scripts working correctly!


My only problem is on this page…

http://jennyw2.netfirms.com/mailing_list.htm

I can’t send in an email address. Nothing happens. I enter an address, press Go! and nothing sends, I’m just transferred to a page that doesn’t exist.

What do you think the problem could be?

P.S. Even though the Form above doesn’t send email addresses yet, I was able to successfully test the .cgi script because there’s field for adding email addresses to the mailing list within the admin section.

http://jennyw2.netfirms.com/cgi-bin/mail-admin.pl

Thanks,
Jenny



mhx
Enthusiast / Moderator

Jun 11, 2001, 12:11 PM

Post #83 of 123 (6650 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,


In Reply To
What do you think the problem could be?

That's super-easy! It's the path to the cgi-script. Just change

Code
<form action="cgi-bin/list/maillist.pl" method="post">

to

Code
<form action="cgi-bin/maillist.pl" method="post">

and everything should work just file!
As you will see, I've added myself to the list...

Bye,
Marcus



JennyW
journeyman

Jun 12, 2001, 4:51 PM

Post #84 of 123 (6634 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus!

Thanks for correcting my Form’s path to point to my .cgi script! I appreciate it!

I have a few questions for you. ~

If you look at this page…

http://jennyw2.netfirms.com/mailing_list.htm

You’ll notice that there are two radio buttons – Subscribe and Unsubscribe.
I don’t like this at all. I want to get rid of both the radio buttons.

When someone signs up for my mailing list all I want him/her to do is enter their email address and then select GO! I don’t want them to have to check the radio button (Subscribe).

How do you think I can do this?

I want to do the same thing for Unsubscribing. I want to make a separate page for Unsubscribing (don’t want radio buttons).

Is it possible to do this?

If you go to this page again…

http://jennyw2.netfirms.com/mailing_list.htm

and enter this email address…

chaaaaaa@hotmail.com

You’ll get one of five .cgi messages. In this case you will get the “email address already in database” message. Now this is fine. But the page the messages show up on looks so plain. The page is .cgi generated, calls two scripts (below), is located within the .cgi-bin, and is at a chmod of 777.

Here’s the url’s to those .cgi scripts that are called…

http://jennyw2.netfirms.com/006_dheader.txt

http://jennyw2.netfirms.com/007_dfooter.txt

Now, I have a page that I designed specifically for my website. It has images, links and a menu etc. I want to make that page appear after someone enters an email address in the Form field.

Is it possible to do this?

Do I just cut-and-paste my html in the documents above?

Since the documents above are in the .cgi-bin and my html images are in the www-bin do I need to specify a path to my images like this…

../image_example.html

…to point to the images so they can be displayed when the page is called upon?

Thanks for taking the time to read all this nonsense!
Jenny



mhx
Enthusiast / Moderator

Jun 12, 2001, 10:05 PM

Post #85 of 123 (6625 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,


In Reply To
How do you think I can do this?
I want to do the same thing for Unsubscribing. I want to make a separate page for Unsubscribing (don’t want radio buttons).
Is it possible to do this?

Yes, I think you can get rid of the radio buttons. But IMO adding a second page for unsubscribing is real overkill. Personally, I'd prefer to have one page, without radio buttons, but with two push buttons, one for 'Subscribe' and one for 'Unsubscribe'. So there will be no radios, and the 'GO!' push button is replaced by the two other buttons. This can be easily implemented in both, the html and the cgi. I can have a look at them again later, but I gotta work now. Wink
I'll also have a look at the redirection stuff you mentioned below. Only two things for now:

In Reply To
Since the documents above are in the .cgi-bin and my html images are in the www-bin do I need to specify a path to my images like this…
../image_example.html

First, you www directory isn't www-bin. cgi-bin has the bin in the name because it contains (mainly) binary files that are about to be executed.
Second, if you refer to an image, this image shouldn't be called .html. Nevertheless, your idea with the path is absolutely ok.
I just took the time to look at some of the links above. Yes, I think cut&paste should work quite well for your very plain looking pages. Just try it. There's only one way to become a good programmer: practice, practice, practice! Even if you're failing, there should always be something you've learned from it!

Bye,
Marcus




JennyW
journeyman

Jun 18, 2001, 10:11 AM

Post #86 of 123 (6589 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus! I missed you!!
Did you have a good weekend?

Ok, I tried cutting-and-pasting my html in the documents (below) and everything worked great!

http://jennyw2.netfirms.com/006_dheader.txt

http://jennyw2.netfirms.com/007_dfooter.txt

Subscribing and Unsubscribing

I really want two separate pages for both Subscribing and Unsubscribing. I want to get rid of the radio buttons and just have a submit button for both.

How can I do this?

Do I have to make any adjustments to my .cgi script if I want to make these changes?


I have another basic question.

As you know, I have .cgi files, which are located in my cgi-bin.
Some of the .cgi files generate html and call images from my www directory, so as you’ve explained in the past, I use the following command to get the image:

../my_image.gif

This works great! But what would I do if I had several directories in my www directory?

For example, how would I adjust the command above if I had a directory named jennyw_menu within my www directory that had html and images that are being called upon by a .cgi script?

Hope all is well!
Jenny



mhx
Enthusiast / Moderator

Jun 18, 2001, 12:40 PM

Post #87 of 123 (6586 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny!

Yeah, my weekend was fine, although it has also been quite exertive. I've managed to look in the forum once or twice, but I wasn't sure if I would get that opportunity.
Now, let's go ahead to your questions:

In Reply To
I really want two separate pages for both Subscribing and Unsubscribing. I want to get rid of the radio buttons and just have a submit button for both.
How can I do this?
Do I have to make any adjustments to my .cgi script if I want to make these changes?

Yes, you can do this and no, you've don't even have to make changes. The only thing you'll have to change is in the HTML files. Remove the radio buttons and replace them by

Code
<input type=hidden name="action" value="subscribe">

for your subscribe page and

Code
<input type=hidden name="action" value="unsubscribe">

for your unsubscribe page. That should be all you've got to do.

In Reply To
For example, how would I adjust the command above if I had a directory named jennyw_menu within my www directory that had html and images that are being called upon by a .cgi script?

That's simple. Just use something like

Code
../jennyw_menu/jennyw_pic.gif

Hope that answers your questions, and hope you're doing fine, too.

Bye,
Marcus



JennyW
journeyman

Jun 19, 2001, 6:28 AM

Post #88 of 123 (6576 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus,
Glad to see you’re back!

I’ll replace the radio buttons with…

SUBSCRIBE
<input type=hidden name="action" value="subscribe">

UNSUBSCRIBE
<input type=hidden name="action" value="unsubscribe">

But what do I do with this piece of code (below)? Do I leave it in the Form?


Code
<input type="submit" value="GO!">


I’m assuming I have to keep it in the Form because of the submit action?

What does input type=hidden mean?

In Reply To
That's simple. Just use something like
../jennyw_menu/jennyw_pic.gif

Thanks! I thought it might be something like that, I just wanted to make sure!

=======================

When I send all the subscribers in my mailing list an email I receive a confirmation email, stating that my message was sent to everyone. However, my name shows up like this (below) in my inbox when I receive that confirmation:


Code
Jenny W themustache@...

But the recipients of my mailing list see my name like this (which is correct)…


Code
Jenny W

How can I get

Code
JennyW themustache@…

to display the following in my inbox?


Code
Jenny W



This isn’t a major concern at all. I’m just curious if there’s a fix for the problem.

Thanks!!
Jenny



mhx
Enthusiast / Moderator

Jun 19, 2001, 7:25 AM

Post #89 of 123 (6574 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi,


In Reply To
But what do I do with this piece of code (below)? Do I leave it in the Form?

Yes, your assumption is right. You need that piece of code for the submit button.

In Reply To
What does input type=hidden mean?

This is simply a hidden field in a HTML form. 'hidden' means it's not visible to the user, but it contains information, in this case what action to perform.
Concerning the email address thing, I don't really understand the problem yet. Can you tell me which script is responsible for sending this confirmation email and where I can find it? I'm sure there's a solution.

Bye,
Marcus



JennyW
journeyman

Jun 19, 2001, 8:25 AM

Post #90 of 123 (6573 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus,

Do you need any more info., regarding my explanation of the email problem?

I believe the first script sends the confirmation email, but I added two others in case I’m wrong.

http://jennyw2.netfirms.com/002_mail-admin.txt

http://jennyw2.netfirms.com/001_cfg.txt

http://jennyw2.netfirms.com/003_maillist.txt

If there’s anything else you need, then let me know~!

Thanks,
Jenny



mhx
Enthusiast / Moderator

Jun 19, 2001, 11:38 AM

Post #91 of 123 (6569 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

yeah, I got it...
The problem is here

Code
sub process_complete { 
open (MAIL, "|$mailprog") or &error("Unable to open the mail program");
print MAIL "To: $yourmail\n";
print MAIL "From: $yourmail<Mailing List $version>\n";
print MAIL "Subject: Message has been sent to all subscribers! Mailing List $version\n";
print MAIL "Message has been sent to all subscribers!\n";
close(MAIL);
}

Remove the part in red and try again, I guess it should work then.

Bye,
Marcus



JennyW
journeyman

Jun 19, 2001, 7:01 PM

Post #92 of 123 (6560 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hey Marcus,

I always wanted to ask you…

What does ”mhx” mean?

Your help is invaluable! Both of your solutions worked wonders!

I adjusted the portion in red and my name showed up as Jenny W in my inbox!

Thanks to your help, I also have two separate pages for subscribing and unsubscribing! I adjusted the code as you directed and it worked great!

Here are my new pages…

http://jennyw2.netfirms.com/mailing_list_subscribe.htm

http://jennyw2.netfirms.com/mailing_list_unsubscribe.htm

I have another question for you…

If you enter an email address in one of the url’s above you will receive one of several messages.
For example, try just entering the following in the Form…

&

Now, press GO!

You’ll receive a message that says…

Unable to subscribe your email address
Please don't use weird symbols


I don’t like where this text is located in the browser window (ignore the text that’s yellow (in the browser) – it’s not in the perl script and doesn’t have anything to do with this question).

I would like the text to be further away from the left side of the browser window. I don’t want it centered, I just want to move it to the right a ‘lil bit.

In the code, I tried applying a <font> tag (below) within the print line.

I applied the following <html> (in purple) to the print line…

print "<font color="#000000">iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii</font>
<h2>Unable to subscribe your email address<h2>\n";

The background of my page is black, which is why I made the i’s black. I thought that would push the Unable to subscribe your email address line over a bit, but it didn’t. When I did this my script wouldn’t work. My browser displayed “Internal Server Error”. I took the font tags out and the script worked again.

I then tried adding the following, but was unsuccessfull…

if ($form{'address'}=~ tr/;<>*|`&$!#()[]{}:'"//) {
&dheader;

print "<font color=\"#000000\";
print " " x 54;
print "</font>\n";

print "<h2><i>Unable to subscribe your email address</i></h2>\n";
print "Please don't use weird symbols
\n";
&dfooter;
exit;
}


I tried another piece of scripting, but again, I was unsuccessfull…

if ($form{'address'}=~ tr/;<>*|`&$!#()[]{}:'"//) {
&dheader;

print qq(
<div style='position:relative;left:200px'>
<h2><i>Unable to subscribe your email address</i></h2>
Please don't use weird symbols</div>
);

&dfooter;
exit;
}

What can I do, to move the text to the left a ‘lil bit?[

Thanks for reading.
Jenny



Pro_4
User

Jun 19, 2001, 7:48 PM

Post #93 of 123 (6558 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

You might have just made this a typo in your post but in the :

Code
print "<font color="#000000">iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii</font>  
<h2>Unable to subscribe your email address<h2>\n";

You forgot to \ out the = sign for color = "#000000".

Sooooo, it would look like this:

Code
print "<font color=\"#000000">iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii</font> 
<h2>Unable to subscribe your email address<h2>\n";

Hope that helps :)

P.S. If that is confusing i am sure mhx will have a brilliant solution.



Yes i am a palm tree. What are you plantist or something!?


mhx
Enthusiast / Moderator

Jun 19, 2001, 11:13 PM

Post #94 of 123 (6557 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

first of all, to answer your most important question Wink:

In Reply To
What does ”mhx” mean?

I was trying to get an email address from one of germany's freemail providers - GMX - several years ago. Because the domain was just @gmx.de, I wanted to have the account name as short as possible. Since my full name is Marcus Holland-Moritz and GMX accounts had to be three letters at least, I tried mhm@gmx.de first. Unfortunately, someone else got this address. So I was searching for something else and ended up with that mhx thing, because it sounded just like gmx. And from then on, I reuse it wherever I can because it sounds and looks quite ok to me. I hope this makes it clearer...
Regarding your text alignment problem, I don't think pro_4's solution will work better than yours. The problem is that the <Hx> tags always start a new row. If you could have had a look at the output with non-black characters, you would have noticed that your iiiiiiiiiii's were printed above the line you were trying to shift left. As always, there's more than one solution to this. I'll give you the one which I think is the clearest (anyone may of course disagree, but I really like tables...).

Code
if ($form{'address'}=~ tr/;<>*|`&$!#()[]{}:'"//) { 
&dheader;

print q(<table><tr><td width="100px"></td><td>
<h2><i>Unable to subscribe your email address</i></h2>
Please don't use weird symbols</td></tr></table>);


&dfooter;
exit;
}

By changing the green text you can adjust the distance from the left margin in pixels. I hope this works as you expect it to.

Bye,
Marcus



JennyW
journeyman

Jun 20, 2001, 5:55 PM

Post #95 of 123 (6545 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus Holland-Moritz,
I too like the nickname mhx, it sounds good!

The scripting you posted worked well on a few of the cgi generated messages, but I’m having trouble applying your code to three messages the script produces.

For each message:
The original scripting is colored in purple.
My adjustments using your scripts are highlighted in blue.

foreach $list(@list) {
if ($list =~ /$form{'address'}/i) {
&dheader;
print "<h2>Unable to subscribe your email address</h2>\n";
print "The email address \"$form{'address'}\" is already in the database
\n";
#print "Please click <a href=\"$main_page\">here</a> to return to our main page.
\n";
&dfooter;
exit;
}
}


foreach $list(@list) {
if ($list =~ /$form{'address'}/i) {
&dheader;
print q(<table><tr><td width="100px"></td><td>
<h2><i>Unable to subscribe your email address</i></h2>
The email address \"$form{'address'}\" is already in the database</td></tr></table>);
#print "Please click <a href=\"$main_page\">here</a> to return to our main page.
\n";
&dfooter;
exit;
}
}

===============================

&dheader;
print "
\"$form{'address'}\" was successfully removed from the database
\n";
#print "Please click <a href=\"$main_page\">here</a> to return to our main page.
\n";
&dfooter;
exit;
}
}

&dheader;
print q(<table><tr><td width="100px"></td><td>
\"$form{'address'}\" was successfully removed from the database</td></tr></table>);
#print "Please click <a href=\"$main_page\">here</a> to return to our main page.
\n";
&dfooter;
exit;
}
}


===============================

&dheader;
print "
\"$form{'address'}\" was not found in the database
\n";
#print "Please click <a href=\"$main_page\">here</a> to return to our main page.
\n";
&dfooter;
}


&dheader;
print q(<table><tr><td width="100px"></td><td>
\"$form{'address'}\" was not found in the database</td></tr></table>);
#print "Please click <a href=\"$main_page\">here</a> to return to our main page.
\n";
&dfooter;
}


I tried adding quotes and < br > tags within the updated script, but I had no luck, the script still wouldn’t show the email address submitted through the Form.

Do you know what could be wrong?

Thanks,
Jenny



mhx
Enthusiast / Moderator

Jun 21, 2001, 1:30 AM

Post #96 of 123 (6542 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

yes, I do know what is wrong Smile.
The problem is that I used 'non-interpolative' or single quoting on the string using the q() operator. Hmmm, I guess I've got to tell you about the difference between single and double quoting...
Ok. If (in Perl) you want a string to appear as it is, you put single quotes around it or you use q(). If you have any variable names in the string, e.g. $form{'address'} this name (and not its content) will appear in the string. If instead you want the content of variables to appear inside the string, you use double quotes or qq() for so-called interpolative quoting. Then, each variable inside the string is replaced by its content. Now, here are some examples to make this clearer:

Code
$name = "Jenny"; 
print 'Hello $name!'; # prints: Hello $name!
print q(Hello $name!); # prints: Hello $name!
print "Hello \$name!"; # prints: Hello $name!
print "Hello $name!"; # prints: Hello Jenny!
print qq(Hello $name!); # prints: Hello Jenny!
print qq(Hello "$name"!); # prints: Hello "Jenny"!
print "Hello \"$name\"!"; # prints: Hello "Jenny"!
print "Hello "$name"!"; # is an error !!!
print 'Hello "$name"!'; # prints: Hello "$name"!

Now, perhaps you may have realized where the problem is. I've used q(), so no variable interpolation is done. If you use qq() instead, the code should work as far as I can see right now. You can also remove the backslashes before the double quotes, because you don't have to escape them inside a qq(). I'd guess that's all you've got to do to solve your problem, just turn q into qq.
BTW: You should have noticed that, instead of the address, \"$form{'address'}\" was printed out in the HTML?

Bye,
Marcus



JennyW
journeyman

Jun 21, 2001, 7:47 PM

Post #97 of 123 (6529 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus!

In Reply To
You should have noticed that, instead of the address, \"$form{'address'}\" was printed out in the HTML?

Yep, I sure did notice! Thanks for mentioning though.

I followed the steps you posted today and adjusted my maillist.pl script. Everything worked great!
I added a q and deleted the backslashes ( \ ) to the three segments of script that required changes.

I’m sure you’ve heard this before, but you are a really good teacher. I’ve been on quite a few of these technical forums and you are by far the best and most straight forward teacher that I’ve come across.

Like usual I have another question for you.

As you know, after I press the GO! Button to subscribe or unsubscribe an email address I’m brought to a new results page generated by a .cgi script.

Instead of going to a whole new page I was wondering if I could generate a popup window with the results of my subscription or unsubscription.

Basically, I’m want the script to do the same thing it’s doing right now, except instead of going to a whole new cgi page, I would like a popup window instead.

Here’s the code for a simple popup window…

<a href="popup_test.htm" onClick="window.open('popup_test.htm','popup','scrollbars=no,resizable=0,width=320,height=132'); return false">Jenny’s Popup Test</a>

Is it possible to do this?

Thanks again and again!
Jenny



mhx
Enthusiast / Moderator

Jun 22, 2001, 5:53 PM

Post #98 of 123 (6520 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,


In Reply To
I’m sure you’ve heard this before, but you are a really good teacher. I’ve been on quite a few of these technical forums and you are by far the best and most straight forward teacher that I’ve come across.

Thanks a lot. Perhaps I have the wrong occupation? Wink
The popup window shouldn't be a problem, I think. But what do you want to happen besides a windows popping up that notifies the user he has been added to / removed from the mailing list? Do you want to stay on the subscribe/unsubscribe page? Do you want to go somewhere else?
Please tell me what exactly you want to happen and I'll try my very best to help you. But now I've got to get some sleep, it's 3 am. Time passes by so quickly in front of a computer...

Bye,
Marcus



JennyW
journeyman

Jun 23, 2001, 5:25 AM

Post #99 of 123 (6517 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi mhx!! It’s Saturday!!

In Reply To
But what do you want to happen besides a windows popping up that notifies the user he has been added to / removed from the mailing list? Do you want to stay on the subscribe/unsubscribe page? Do you want to go somewhere else?

That’s a good question. It annoys me that I didn’t think of it. Thanks.

SUBSCRIBE
I want the Subscribe page to stay on the subscribe page (so I don’t want this page to transfer anywhere).

UNSUBSCRIBE
I want the Unsubscribe page to transfer to another page after the popup window appears. Let’s say, my index page.

In the future I can obviously configure which page I want to transfer to right?

Will it be difficult to change if at a later date I decide I want the SUBSCRIBE page to actually make a transfer to another page?


Thanks for keeping me on my toes!
Jenny



mhx
Enthusiast / Moderator

Jun 23, 2001, 8:54 AM

Post #100 of 123 (6514 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

I really, really hate to say that, but I don't have an answer for you this time. Frown
I've been thinking about the problem for some time now and didn't find a simple solution. I'm sure there is a solution, but it could mean an awful lot of work to modify the script. Perhaps I'm wrong and there is a simple solution, but if so, it didn't come to my mind yet. Perhaps because I didn't sleep that much. Wink
So, I'm not going to stop thinking about it and if I got an idea, be sure I'll tell you. But it may be that you'll have to live with you current script...
Sorry, no help this time. Anyway, I wish you a nice weekend.

Bye,
Marcus



JennyW
journeyman

Jun 23, 2001, 10:26 AM

Post #101 of 123 (7497 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi mhx, Marcus and Marcus Holland-Moritz,
Are you all having a good weekend?


In Reply To
I really, really hate to say that, but I don't have an answer for you this time.

That’s ok. You’ve been so helpful in every way imaginable.
However, I’m all ears (I will be very interested) if you ever think of a solution.

When I send an email to the addresses on my mailing list, the recipients all receive my written message in their inbox. When they get that message they can also see my email address.

I do not want my email address to be:

1. Visible to the recipient.
2. I don’t want to give the recipient the ability to Reply and send a message to the sending email address in the email.

Is it possible to do this?

Thanks,
Jenny



mhx
Enthusiast / Moderator

Jun 23, 2001, 1:16 PM

Post #102 of 123 (7495 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

I'm not 100% sure, but I don't think it's possible to show your name (which I guess you still want to show) without an e-mail address.
There are two possibilities you have. First, you don't specify anything. If you do so, a default e-mail address (some weird number @netfirms.com) will be inserted as the sender.
Second, you specify an address. I've looked up the abstract syntax description for e-mail addresses and found that it's not possible to specify a name without an address. So, the easiest thing to do is to use a dummy e-mail address.
I also don't think that it's possible to disable the receiver's option to reply. Simply because there has to be a sender e-mail address.
I'm sure you also get a lot of spam. In my hotmail account which I've created 5 years ago, I got 250 addresses on my blocked senders list and still receive about 20 spam mails per day. That's why I don't use the account anymore. Have you ever seen that any of these mails didn't have a sender address? I haven't. And I'm sure if it was possible to send anonymous mail (such as you want to) most of the spam mail were anonymous.
As another example, a lot of mails I receive contain a special notice that you shouldn't reply to them because they were automatically generated. If you could block the receiver's reply option, this wouldn't be neccessary.
You see, I'm not absolutely sure, but I don't think it's possible. If you don't want the users to see your e-mail, get a dummy account and use this instead of your real account. I don't have a better solution currently, and I don't think there is a really good solution to this.

Bye,
Marcus

PS: "I’m all ears" is almost the same in german ("ich bin ganz Ohr"). Thanks for the explanation anyway!



JennyW
journeyman

Jun 25, 2001, 9:36 AM

Post #103 of 123 (7483 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus!

Did you have a good weekend?
I went to the zoo yesterday with a few friends. When I got home I was darn tired!

In Reply To
I've looked up the abstract syntax description for e-mail addresses and found that it's not possible to specify a name without an address. So, the easiest thing to do is to use a dummy e-mail address.
I also don't think that it's possible to disable the receiver's option to reply. Simply because there has to be a sender e-mail address.

I guess I’ll use a dummy address, it’s not a big deal. I wasn’t totally sure if I wanted to implement these changes (if they were possible) anyway, I just wanted the option.

The only thing I have left to do for my mailing list script is to check to see how many people it can store and send email to.

=====================================================

Off to new and better things…

I have a perl script that dynamically places a Poll on an html page, but I can’t seem to get it working.

I uploaded, chmod’ed and made script adjustments to all the files that related to the script. I followed every step specified in the readme file (I obviously went wrong somewhere, but I’ll soon get to that!)

Here’s my poll’s url…

http://jennyw3.netfirms.com/cgi-bin/poll_it_ssi.cgi

In order to dynamically insert this poll on a webpage the readme file directed me to perform the following (I followed the portions highlighted in purple)…

README
The filename packaged w/ this script named 'Poll_It_SSI.cgi'
is the CGI Script used w/ SSI (Server Side Includes) to import
your poll on an existing web page.

To use SSI within HTML files, most servers require your web page
name to have an *.shtml extension rather than *.html. This allows
you to execute a command to include a CGI Output in your html file.


Some servers (Unix/Apache) you can enter a file named '.htaccess'
with the contents:

AddType text/x-server-parsed-html .html

Inside of it (make sure that line above has a return after it)

What this file will do is tell the server to parse HTML files
in that directory w/ .html files, allowing you use *.html files
with SSI instead of renaming to *.shtml.

Now to input the Poll_It_SSI.cgi script into an HTML page, use this
code (After finding out what you need to use for SSI calls from the
above explanation):


< !--#exec cgi="path/to/Poll_It_SSI.cgi" -- >

The above tag will look for the *.cgi file at the location specified
& if there will output your current poll running into your web page.


I inserted the script above into an .shtml file, so I could view the poll in a webpage, but I received an error.

Here’s the error…


Code
[an error occurred while processing this directive]

Here’s the url for the error above…

http://jennyw3.netfirms.com/002_ssi_test.shtml

I tried another SSI script (date script) to make sure I was doing the .shtml thing correctly and received a successful output…
I inserted the following SSI into an .shtml page…

< !--#echo var="DATE_LOCAL" -- >

Here were my successful results…

http://jennyw3.netfirms.com/001_ssi_test.shtml

Do you know what I could be doing wrong?

If it’s necessary, here’s the full readme doc…
http://jennyw3.netfirms.com/text_files_for_viewing_only/INSTALL_Poll_It_v2.05.txt

If you need any more information just holler – JENNY!!

Thanks,
Jenny



mhx
Enthusiast / Moderator

Jun 25, 2001, 11:42 AM

Post #104 of 123 (7480 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

JENNIEEEE!

(sorry, but you asked for shouting ;-)
Yeah, there are two things that I'd like to have a look at. First, it's the CGI-script itself (poll_it_ssi.cgi) and second, it's the source code of the SHTML file (002_ssi_test.shtml). Unfortunately, since it's a server side include, it's not the original source code that I receive when requesting the URL.
If you could be so kind and link me to these files, I'll try to figure out what went wrong. This again is something new to me, since I haven't used SSI before, but it doesn't seem to be so special.
Oh, yes, my weekend was fine so far. We're slowly getting closer to summer where I live, so I took the opportunity to cycle around and take a few photographs in my surrounding area. Some are quite cool!

Bye,
Marcus



JennyW
journeyman

Jun 25, 2001, 5:56 PM

Post #105 of 123 (7473 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi mhx!

Here’s the two links you requested:

1. The CGI script

http://jennyw3.netfirms.com/text_files_for_viewing_only/poll_it_ssi.txt

2. The HTML document

http://jennyw3.netfirms.com/text_files_for_viewing_only/002_ssi_test.txt


In Reply To
This again is something new to me, since I haven't used SSI before, but it doesn't seem to be so special.

Yes, SSI is new to me too. However, like you it doesn’t seem too too complicated, but then again, I can’t seem to figure out the problem.


In Reply To
Oh, yes, my weekend was fine so far. We're slowly getting closer to summer where I live, so I took the opportunity to cycle around and take a few photographs in my surrounding area. Some are quite cool!

What’s the present temperature of your climate right now?
You take photography? That’s cool. What do you enjoy taking pictures of?


Take care,
Jenny



mhx
Enthusiast / Moderator

Jun 26, 2001, 10:37 AM

Post #106 of 123 (7466 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny!

Unfortunately, I have the answer for your problem. It's in the Netfirms SSI FAQ:

In Reply To
Q - Why can't I execute CGI (perl) scripts within my webpage using the #exec cgi command?
A - At this point Netfirms does not provide #exec-cgi functionality - although you can still use scripts from your CGI-BIN directory.

The script itself really isn't the problem. It worked absolutely smooth with my local Apache server. You didn't make any mistake.
Bad news, I know, but perhaps they're going to fix this annoying - and IMO unneccessary - problem. I just started to like SSI, but if I cannot use it...
But now, let's move on to more positive things!

In Reply To
What’s the present temperature of your climate right now?

Well, today it got really hot! We're having about 34 degrees Celsius. (Are you familiar with Celsius? If you prefer Fahrenheit, this is about 93 degrees.) My thermometer tells me something about 78 (172) degrees, but this is in the direct sun. (I can tell you, this is not the right weather to cycle in black clothes ;-) In my basement flat it's cool 20 (68) degrees, very nice if you come from outside. Smile

In Reply To
You take photography? That’s cool. What do you enjoy taking pictures of?

Ooo, just about everything. Nothing and no-one is safe if I take my cameras along! I got several thousand slides, and since I have my digital camera, I don't even have to care about films. (I enjoy using my 'analogue' cameras more than the digital one, but it's easier to carry along.)
I really like macro-photography, so I find my favourite motifs in nature. I also like taking photos of my cats. Last year I consumed eleven films when I was at the EXPO world exposition in Hannover. I'm about to set up a web page with a small photo gallery, but I gotta do some Perl programming before to make this easy to maintain ;-)

Ciao,
Marcus



JennyW
journeyman

Jun 26, 2001, 4:30 PM

Post #107 of 123 (7462 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus,

In Reply To
Q - Why can't I execute CGI (perl) scripts within my webpage using the #exec cgi command?
A - At this point Netfirms does not provide #exec-cgi functionality - although you can still use scripts from your CGI-BIN directory.

This is really really stinky. I remember, when I first signed with netfirms, yes, I remember reading the above – darn.

This is not good and I am going to write them a nice letter about this.

Do you know any free websites that provide #exec-cgi functionality?

In Reply To
The script itself really isn't the problem. It worked absolutely smooth with my local Apache server. You didn't make any mistake.

Well I’m at least glad to hear I did something right! I hope I can test this in the near future!

How did it look on your server? Did it show up on the webpage that had the SSI command in the code?

In Reply To
Are you familiar with Celsius?

I sure am familiar with Celsius! I love the warm weather, it feels so great on the skin!

In Reply To
Last year I consumed eleven films when I was at the EXPO world exposition in Hannover. I'm about to set up a web page with a small photo gallery, but I gotta do some Perl programming before to make this easy to maintain ;-)

I’m not too familiar with Germany. Where is Hanover located (East or West Germany?)

Let me know when that photo gallery hits the web!

Take care,
Jenny



mhx
Enthusiast / Moderator

Jun 26, 2001, 8:52 PM

Post #108 of 123 (7456 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Good morning, Jenny!


In Reply To
Do you know any free websites that provide #exec-cgi functionality?

Yes, I know (since about 5 Minutes... :-). At prohosting you can sign up for a 50 MB account with full CGI/SSI support. But: They don't have support for sendmail... As soon as I find a provider that offers everything and costs nothing, I'm going to tell you.

In Reply To
How did it look on your server? Did it show up on the webpage that had the SSI command in the code?

Yeah, it showed up just as expected. Have a look here to see it.

In Reply To
Where is Hanover located (East or West Germany?)

Mmmh. First, there's no more East or West Germany since about 12 years now. At least they're no longer separated since then. But to answer your question, Hannover is in the center of the north of Germany. If you know Frankfurt and Hamburg, it's somewhere in between. Germany isn't so big, so this description should locate it within a radius of 100 km ;-)
Be sure I'll keep you informed about the photo gallery. I'm currently working on a Perl script that extracts the tags my digital camera stores from the pictures, so I can display technical details for each photography. Also, I'm going to write some HTTP upload script, since I'm a lazy person and do not have FTP access everywhere.
What I would be interested in: What do you have to pay your ISP for your internet connection? Does it depend upon the time you're online? Or is it just a (monthly) payment with unlimited online time included? And how fast is your connection? I'm really curious about these...

Bye,
Marcus



JennyW
journeyman

Jun 27, 2001, 9:38 AM

Post #109 of 123 (7446 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus!!


In Reply To
Yes, I know (since about 5 Minutes... :-). At prohosting you can sign up for a 50 MB account with full CGI/SSI support. But: They don't have support for sendmail... As soon as I find a provider that offers everything and costs nothing, I'm going to tell you.

Wow! This is great! Thanks for the url, this will help me a lot!

Prohosting Writes (important text highlighted in red)…

In Reply To
Question: How do I use CGI scripts?
Answer: Here are some key points to remember when working with CGI scripts.

&#61623; You can run CGI scripts from anywhere within your directory structure, however, we have created a cgi-bin folder for organizational purposes.
&#61623; File names must end in .cgi or .pl to work propperly
&#61623; Set the permissions(chmod) on ALL CGI scripts to 755(rwx rx rx) regardless of what your CGi scripts instructions direct you to do.
&#61623; Set the permissions(chmod) on ALL directories to 755(rwx rx rx) regardless of what your CGi scripts instructions direct you to do.

&#61623; Upload your CGI scripts in ASCII mode. If you upload them in Binary mode they will not work.


Is it OK to IGNORE the permission requirements that my Poll readme file directs me to apply to my .cgi scripts?

Also, thanks for posting my SSI test with your webspace!

I’ve signed up with Prohosting, but first I have another question for you!

===================================================

I found a .cgi script for a Guestbook. Now, so far I’m doing pretty well (I think), well actually, I’m not doing the best, I need your assistance.
I don’t like incorporating two topics (Poll / Guestbook) in the same post (because it gets the posts a bit messy), but I’m gonna do it just this once.

After I uploaded my Guestbook scripts I was directed to point to my setup.cgi url and key in some setup information.

I successfully filled out all of the fields, except for this one…


In Reply To
Server location of listings.html, main_layout.html, problem.html and thanks.html
Fictional Example: /home/yourdomain/www/guestfriend

What is the Server Location? I know what URL Location is, but not Server.

Also, when viewed, the .cgi scripts the Guestbook zip file supplied me with were all jumbled. For example, the whole script was just bunched up into a clump.
I wanted your opinion as to why these scripts looked like this so I made them into .txt files and uploaded them to my webspace. After uploading, the scripts became readable (just like all the other scripts I’ve shown you).

I’ll have to attach a script (to perlguru) for you. I will do that later so you can see what I’m talking about.

What’s the most populated city in Germany? How many people live there?

I love digital cameras, but they’re so expensive. When they get down to my price range then I’ll have to think about picking one up, but that won’t be for a while.


In Reply To
What do you have to pay your ISP for your internet connection?

I pay $40 a month.


In Reply To
Does it depend upon the time you're online? Or is it just a (monthly) payment with unlimited online time included?

I have unlimited monthly access.


In Reply To
And how fast is your connection?

I run my internet connection through cable. I’m not too sure what the exact speed is. I think it’s like 300 or something?

You’re the best Marcus!
Jenny



mhx
Enthusiast / Moderator

Jun 27, 2001, 11:27 AM

Post #110 of 123 (7444 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

I've been searching all day for a free webhoster that provides CGI, SSI, FTP and sendmail, but I gave up. Seems that you have to combine the netfirms and the prohosting account. I'm going to use the prohosting account for my photo gallery, since there's more space and no real need for email. Even better if the URL helped you, too. Smile
Concerning the file permissions, I'd rather trust the provider than the script author. The script author isn't wrong, but he cannot know how your server is configured. The guys at prohosting should know it.

In Reply To
What is the Server Location? I know what URL Location is, but not Server.

The server location is, well, simply the location of that file on the server. I guess this will not actually help you...
To clarify this, think of your own computer, where you have installed Apache (I think you have). There's a directory on your harddisk where you put the files that you can access by typing a URL like http://localhost/jenny.html. Let's say that jenny.html is located in c:\webserver\www\jenny.html. Then the red one is the URL and the green one is the Server Location. That was hard to explain, I hope you got it.
Since most webservers are currently running some sort of UNIX, the directory you have been assigned is most likely to be located somewhere in the /home directory.
Anyway, I don't think you actually need the server locations. I guess you can also use relative locations instead. Which means, if your CGI-files are in /home/some/where/cgi-bin/ and the HTML files are in /home/some/where/, you don't have to use /home/some/where/listings.html, but can also use ../listings.html.
Some providers don't allow relative addressing, but many do allow it. Don't care about the absolute server location unless you need it.

In Reply To
Also, when viewed, the .cgi scripts the Guestbook zip file supplied me with were all jumbled. For example, the whole script was just bunched up into a clump.

I don't think you have to post the file, I can imagine why they looked that way. I'd guess these files we're in UNIX format, and you tried to open them with Notepad. If this was (more or less) the case, try to open such a file with WordPad. If it looks normal then, my thought was right, and you don't have to attach a file.

In Reply To
What’s the most populated city in Germany? How many people live there?

It's definetely not Hannover, although it's quite a big city (they have half a million citizens). The most populated cities are Berlin (3.4 million) and Hamburg (1.6 million). I live in Gärtringen, which is in the south-west of Germany, quite close to France. We've got less than 5000 people living here.

In Reply To
I love digital cameras, but they’re so expensive. When they get down to my price range then I’ll have to think about picking one up, but that won’t be for a while.

Yes, they're nice toys, and yes they're expensive. But they still can't reach the quality of my 'analogue' (or as a friend of mine would call it 'chemical') cameras. Do you have a normal camera?
The $40 are a fair price I think. A similar connection in Germany is slightly more expensive. Currently, I have to pay less than one cent per minute, which is ok for me since I have internet access at work and only need it when I'm at home. Normally my phone bill (including internet) is less than $20.

Bye,
Marcus



JennyW
journeyman

Jun 28, 2001, 6:42 AM

Post #111 of 123 (7429 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hello Marcus!

PROHOSTING

I can’t upload to my Prohosting account.

Every time I try to upload a file I receive this message (my files won’t upload)…


Code
Connected to 2093.90.125.203 port 59438


Code
STOR index.html


Code
503 No PORT command issue first

Do you know what could be wrong?
====================================
GUESTBOOK


In Reply To
To clarify this, think of your own computer, where you have installed Apache (I think you have). There's a directory on your harddisk where you put the files that you can access by typing a URL like http://localhost/jenny.html. Let's say that jenny.html is located in c:\webserver\www\jenny.html. Then the red one is the URL and the green one is the Server Location. That was hard to explain, I hope you got it.

Just to let you know, this was a darn good explanation!

However, I think I need to know the Server Location of where my files are.

If you go to the link below (setup.cgi page) you’ll see the setup requirements for my Guestbook. (Please don’t submit any info. on this form!)

http://jennyw4.netfirms.com/cgi-bin/setup.cgi

The third field on the page (above) displays the following

Server location of listings.html, main_layout.html, problem.html and thanks.html
Fictional Example: /home/yourdomain/www/guestfriend

Now, I entered ../ (the relative location you taught me) in the field above, and my setup.cgi script said that I successfully went through the setup procedure.

So I went to check out my guestbook.cgi page. This is the page where people are suppose to be able to sign my guestbook, but nothing showed up on the page – it was blank.

Here’s the url of my blank Guestbook page…

http://jennyw4.netfirms.com/cgi-bin/guestbook.cgi

I figure I need the exact Server Location to point to the exact path. What do you think? Do you think that’s the case?

Here’s the Guestbooks Readme.txt file. I don’t know if you need it or not, but here it is…

http://jennyw4.netfirms.com/text_files_for_viewing_only/readme.txt
====================================
EDITING


In Reply To
I don't think you have to post the file, I can imagine why they looked that way. I'd guess these files we're in UNIX format, and you tried to open them with Notepad. If this was (more or less) the case, try to open such a file with WordPad. If it looks normal then, my thought was right, and you don't have to attach a file.

You were right! I opened the .cgi files in Wordpad and the scripts displayed properly (organized).

When editing / saving .cgi or .html files does it matter whether I use WordPad or Notepad?

What’s the difference between the two (Wordpad & Notepad)? Will I have to upload differently if I use Wordpad?


In Reply To
Yes, they're nice toys, and yes they're expensive. But they still can't reach the quality of my 'analogue' (or as a friend of mine would call it 'chemical') cameras. Do you have a normal camera?

Yes, I have a normal Samsung camera. I don’t have to set apertures or F16’s. It has a small zoom lens and does everything itself – I’m not too professional when it comes to photography!

Bye Marcus,
Jenny



mhx
Enthusiast / Moderator

Jun 28, 2001, 8:25 AM

Post #112 of 123 (7425 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

first, are you sure this was the output:

Code
Connected to 2093.90.125.203 port 59438

If so, the IP-address is definetely wrong. Each of the four numbers can be at most 255, so I'd guess there's a typo and you meant 203. (Quiz: Try to think of why I say 203 and not 209 or something else...)

Uploading to prohosting's account was absolutely fine when I tried. Did you enter the IP-address or did you enter the hostname of the server (mine is odin.prohosting.com)?


In Reply To
What do you think? Do you think that’s the case?

Maybe. At least, I'd give it a try. Run the following CGI-script on the server, it should give you the path to your cgi directory.

Code
#!/usr/bin/perl -w 
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
use Cwd;
use strict;

print header, start_html, h1( cwd ), end_html;

You can modify the directory to point where your files are located. If your 'cgi-bin' and 'www' directories are in the same directory, just replace cgi-bin with www.

In Reply To
What’s the difference between the two (Wordpad & Notepad)? Will I have to upload differently if I use Wordpad?

The difference is simple. Notepad is just an ASCII editor, while WordPad is a (very) simple version of Word. Unfortunately, Notepad requires files to be in DOS format to display correctly. I personally wouldn't use WordPad for editing source code in general. I'd recommend getting an Editor that supports the Unix format instead. You can give it a try with WordPad, but always remember to save your files in ASCII format, not RTF or Word-Format. You have to upload your files in ASCII mode, as always.

In Reply To
Yes, I have a normal Samsung camera. I don’t have to set apertures or F16’s. It has a small zoom lens and does everything itself – I’m not too professional when it comes to photography!

I've also started with a pocket camera about fifteen years ago. It didn't even have a zoom. Now, I got two Minoltas from the Dynax series (they call it Maxxum in USA), the 9xi and the 700si, as well as my digital Nikon Coolpix 995. I like them in exactly this order. If you've used the 9xi once, you're 100% addicted! It feels and sounds absolutely great. Smile

Bye,
Marcus



JennyW
journeyman

Jun 28, 2001, 10:34 AM

Post #113 of 123 (7422 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi mhx,

POLL

In Reply To
first, are you sure this was the output:
Connected to 2093.90.125.203 port 59438
If so, the IP-address is definetely wrong. Each of the four numbers can be at most 255, so I'd guess there's a typo and you meant 203.

I’m absolutely positive that was the output. I’m gonna email Prohosting and ask them what could be wrong.


In Reply To
Did you enter the IP-address or did you enter the hostname of the server (mine is odin.prohosting.com)?

I entered the host name – odin.prohosting.com


In Reply To
(Quiz: Try to think of why I say 203 and not 209 or something else...)

Is it because 9 (or some other number) is a randomly generated number used for security purposes?

GUESTBOOK

In Reply To
#!/usr/bin/perl -w
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
use Cwd;
use strict;

print header, start_html, h1( cwd ), end_html;

I’ll run the script above, edit the Guestbook setup file and tell you my results!


In Reply To
If you've used the 9xi once, you're 100% addicted! It feels and sounds absolutely great.

Wowee! You sound like a real pro when it comes to cameras! What do you enjoy doing more: Photography or Perl?

Until next time!
Jenny



mhx
Enthusiast / Moderator

Jun 28, 2001, 11:39 AM

Post #114 of 123 (7421 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,


In Reply To
I’m absolutely positive that was the output. I’m gonna email Prohosting and ask them what could be wrong.

That's really odd. As I said, I didn't have any problems. When I'm back home I'll have a look at what the prohosting server means when I'm logging in.

In Reply To
Is it because 9 (or some other number) is a randomly generated number used for security purposes?

No. Have a look at the number 2093. If you made a typo, the only two numbers that you could have hit with one finger at the same time are 9 and 0. So either of them would have been wrong. Since, as I said, the number can be at most 255, 293 isn't possible. That leaves us with the 0 and that's why I guessed 203. Unfortunately, you didn't make a typo and this weird address must have some other reason. Wink

In Reply To
Wowee! You sound like a real pro when it comes to cameras! What do you enjoy doing more: Photography or Perl?

Mmmh, well, that's hard. I like both of them very much. The problem is, there are some other things that I also like very much (collecting CDs and DVDs, or cooking, to name just a few). Fortunately, Perl and Photography are completely different things, so when you're tired of the one thing, the other thing may just be the right to do. If the weather is fine, I really enjoy Photography more, if I hear the raindrops banging against my window I put the music on and write some Perl (or treat my computer in some other way).

Hope to hear from you,
Marcus



JennyW
journeyman

Jun 29, 2001, 6:06 PM

Post #115 of 123 (7404 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus! The weekend is here! I love it!!!

PROHOSTING

I figured out how to upload scripts (using FTP) to Prohosting! I checked out their FAQ page and used the following info…


In Reply To
7. When I FTP, I get the error "503 error, no port command issued." What's wrong?
In your FTP application, look for a setting called Passive Transfer mode, or PASV mode, and enable it, or disable it... make it the opposite of what it is, and the FTP should work.
Normally, PASV mode enables FTPing through some firewall setups. I couldn't find a reason for the "no port command" error, however, in looking for the answer, I found a site that goes into boring technical detail as to what PASV mode does (but I won't bother you with that URL here).

I disabled the PASV mode and my files uploaded!
=====================================
POLL

Since I can now upload to Prohosting I was able to test my Poll script. It worked! Actually it worked great!!

I’ll most likely have a few questions for you, regarding my poll in the very near future.
=====================================
GUESTBOOK

I uploaded and executed the following script you gave me…

#!/usr/bin/perl -w
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
use Cwd;
use strict;

print header, start_html, h1( cwd ), end_html;


Here were my results…

/home/d01/sec/s20/a0004k5s/cgi-bin

Here’s the url to the script (displays the results listed above)…

http://jennyw4.netfirms.com/cgi-bin/path_to_server.cgi

I imported /home/d01/sec/s20/a0004k5s/www into my setup.cgi file. I sent the info. and it accepted the results.

Here’s the page…

http://jennyw4.netfirms.com/cgi-bin/setup.cgi

Now, my readme file directs me to view my guestbook.cgi page. As you remember last time, when I entered ../ and viewed my guestbook.cgi file nothing showed up on the page.

Well, the opposite occurred this time. I was able to see my guestbook.cgi page. However, there’s still a big problem.

When I make an entry in the guestbook and select the Sign Guestbook button I receive one of two messages:


In Reply To
1. You are getting this error because:
There is no index.html file
or
You do not have the proper access permissions

I have an index.html file


2. HTTP Error 403 – Forbidden
Internet Explorer

Why do you think my guestbook isn’t working?

Here’s the link to my guestbook.cgi page…

http://jennyw4.netfirms.com/cgi-bin/guestbook.cgi

I don’t know if this is necessary, but here’s the readme.txt file for my guestbook…

http://jennyw4.netfirms.com/text_files_for_viewing_only/readme.txt
=====================================
In an unrelated issue…What does Remotely Hosted mean? I keep hearing this term every now and then.
=====================================

In Reply To
The problem is, there are some other things that I also like very much (collecting CDs and DVDs, or cooking, to name just a few).

I loooove listening to music.What are your favorite bands?
You like movies too? What are a few of your favorite movies?


I love The Beatles. My favorite album is Abbey Road. Polythene Pam is my favorite song on the album!

I’m gonna go see A.I. now!

See ya later!!
Jenny



mhx
Enthusiast / Moderator

Jun 29, 2001, 11:03 PM

Post #116 of 123 (7402 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

I'm glad you figured out how to upload your files. I didn't have to configure anything. Also glad to hear your poll is working fine.

The guestbook thing is quite strange. Well, at least my server path script worked as I expected Smile. I've downloaded the guestbook and installed it locally and on netfirms, where you can also test it. I did the following to make it work:

1. I created subdirectories named guestfriend in both the www and the cgi-bin directories
2. I put the following files into cgi-bin/guestfriend/

Code
admin.cgi 
guestbook.cgi
setup.cgi
setup.cfg
data.txt

2. I changed the permissions of all .cgi files to 755
3. I put the following files into www/guestfriend/

Code
listings.html 
logo.gif
main_layout.html
problem.html
thanks.html

4. I executed cwd.cgi on my server and got

Code
/home/d01/sec/s24/a0002e0t/cgi-bin/

5. I executed setup.cgi and entered the following information
The URL location of the CGI scripts

Code
http://mhx.netfirms.com/cgi-bin/guestfriend

URL location where listings.html, main_layout.html, problem.html and thanks.html are located

Code
http://mhx.netfirms.com/guestfriend

Server location of listings.html, main_layout.html, problem.html and thanks.html

Code
/home/d01/sec/s24/a0002e0t/www/guestfriend

Image Parser

Code
Y

6. That's it. The script works absolutely perfect. (Although I'm not going to use it...)

I can't imaging what's wrong with your setup. Best thing would be to try to perform exactly the steps I described and see if it works.


In Reply To
What does Remotely Hosted mean?

That's good. I thought you were the native speaker? Wink I think it's nothing special, IMO just means that your page is hosted (kept) not on your computer, but remotely (far away, e.g. at netfirms).

Bye,
Marcus



JennyW
journeyman

Jul 1, 2001, 11:42 AM

Post #117 of 123 (7388 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus,

GUESTBOOK

In Reply To
I can't imaging what's wrong with your setup. Best thing would be to try to perform exactly the steps I described and see if it works.

I don’t know what could be wrong? I followed your steps exactly. Now when I go to my guestbook.cgi page I get a blank page again. I don’t get it.

Here’s the url to my blank guestbook.cgi page:

http://jennyw4.netfirms.com/cgi-bin/guestfriend/guestbook.cgi

The only thing that was different was your path to the server, compared to mine.

You had: /home/d01/sec/s24/a0002e0t/cgi-bin/
I had: /home/d01/sec/s20/a0004k5s/cgi-bin
I tried both paths and was still unsuccessful.

In Reply To
My Guestbook’s readme file writes:
If you are going to use Java Script in the .html files please turn off the image parser in setup.cgi

I have Java Script I want to apply to my guestbook’s html files, but if I turn off the image parser (N) in the setup.cgi page doesn’t that mean that I will no longer be able to add my own code to the guestbook’s html files?
==========================================
POLL

My poll seems to be working wonderfully! However, I have a very small issue at hand.

Here’s the url to my poll_it page…

http://odin.prohosting.com/jennyw/

Now, make a selection, submit it and wait for the page to reload and give you the results.

The results’ text is in black, but I want it to show up in white. I adjusted all the rest of the text to display in white by editing my _ssi_poll.html page.

I think the reason the text of the results displays in black is because it’s generated within the poll_it_ssi.cgi script.
I tried to locate where I could change the font in the cgi script, but was unsuccessful.

Do you know where or how I can change the font from black to white?

If you need them: here are the .txt (cgi) documents for my polls pages:

http://jennyw3.netfirms.com/text_files_for_viewing_only/poll_it_ssi.txt

http://jennyw3.netfirms.com/text_files_for_viewing_only/Poll.txt

Having a great weekend! Hoping you are too!
Jenny



mhx
Enthusiast / Moderator

Jul 1, 2001, 2:11 PM

Post #118 of 123 (7383 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,


In Reply To
I don’t know what could be wrong? I followed your steps exactly. Now when I go to my guestbook.cgi page I get a blank page again. I don’t get it.

I don't know either. As you can see from the link in my last post, it worked fine for me the way I described it. Have no idea, sorry :-(

In Reply To
Do you know where or how I can change the font from black to white?

That should be easy. You said you already modified your _ssi_poll.html file? Actually, you also have to adjust the color for the results in this file. Here's the section you have to edit and the changes you have to apply are in red.

Code
   >!-- insert : $show_results$ --< 
>!-- def : poll_results --<
>TR<>TD< >Font Face="Verdana,Arial" Size=2 Color="#FFFFFF"<
$image_percent$ $percent$ >BR< $poll_option$ >/TD<>/TR<
>!-- /def : poll_results --<

I have reversed the angle brackets because the forum seemed to have problems with displaying the original code. Of course, you don't have to change these.
My weekend was fine so far, unfortunately it's getting closer to Monday ;-)

-- Marcus



JennyW
journeyman

Jul 2, 2001, 11:34 AM

Post #119 of 123 (7371 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hiee!!

GUESTBOOK


In Reply To
I don't know either. As you can see from the link in my last post, it worked fine for me the way I described it. Have no idea, sorry :-(

That’s ok. I didn’t like the features of the Guestbook that much anyway.
I’m going to look for a new script. I have to find a script where I can add my own html to the Guestbook so it will look like the rest of my site!

===================================================

SERVER SIDE INCLUDES

I really like this SSI stuff and I think I can utilize it quite well.

I want to make a site that has loads of pages.
The borders, menu and logo of this site are all images and all appear on every page on my site.

Right now, if I don’t use SSI and if I want to make changes to any re-appearing images on my site then I’d have to edit those changes individually - on every single page.

However, if I do use SSI, then I can edit those images once and my changes will be applied to every page.

I’m not too sure how I can go about doing this. Do you know how I can get started?

Until next time!
Jenny

Ohh, I almost forgot, thanks for your help with the black text on my Poll. I applied the changes you posted and everything worked great.
Actually, I was a little angry with myself that I didn’t notice that font tag when editing all the other font tags. If I noticed it I definitely would have tried making the font color adjustment.

Thanks so much!



mhx
Enthusiast / Moderator

Jul 2, 2001, 11:48 AM

Post #120 of 123 (7369 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,


In Reply To
I’m not too sure how I can go about doing this. Do you know how I can get started?

As I said, I'm no HTML guru. So I can't give you professional information on this topic. What you are trying to do sounds to me as if you should use frames in your HTML. Perhaps SSI can be useful as well, I don't have experience with that so much. If you don't know about frames and want to see how a site with frames looks, you can have a look at my super-outdated german homepage ;-) As you will see, there's a menu and some java applet on the left, and changing content on the right. I've only written the menu and such once, and used a frameset to display the menu separated from the content. If you go to my absolutely outdated Y2K-page (also in german), you can see something similar.
If you think you like it, I can tell you more about frames. I've used no CGI or SSI or any other sophisticated technique on these pages.

Bye,
Marcus



JennyW
journeyman

Jul 3, 2001, 6:56 PM

Post #121 of 123 (7342 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus!

GUESTBOOK

Well I found another guestbook, but this one’s a little more complicated to configure.

I’m having quite a bit of problems running the script.
First, I’m receiving this message when running it…

In Reply To
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, Your Webmaster and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.

I don’t know what I did to generate this error?

The script I got is called Guestex. You can view it here if you need to:

http://www.cgihk.com/scripts/guestex/

Here’s the link to the readme file for this script:

http://jennyw4.netfirms.com/guestex/for_viewing_only/readme.html

Here are the .cgi / .pl scripts for this guestbook.
Below are two of the same scripts, except one of them has my changes implemented.

Original:

http://jennyw4.netfirms.com/guestex/for_viewing_only/guestex_original.txt

My changes:

http://jennyw4.netfirms.com/guestex/for_viewing_only/guestex.txt

Here’s a .pl file I didn’t edit at all:

http://jennyw4.netfirms.com/guestex/for_viewing_only/guestex.pl.txt

Here’s a few places I think I made errors in (refer to readme link):

2. Editing options

$guestex
# Path to the core part of Guestex, guestex.pl


$guestdata
# Path to the data file

$header
# Path to the HTML header


$footer
# Path to the HTML footer

$rec_temp
# Path to the Record template


$filter
# Domain filter, strongly recommended to set this to your server
# Set to 1 to enable, 0 not to disable

@domains
# Domain filter, strongly recommended to set this to your server
# So that people cannot edit the submission form to perform any unwanted actions
# For multiple domains, write like this -> ("astronomy.org.hk", "anothersite.com")


I don’t know where else I could have gone wrong. I guess in many places. I’m unsure. I know this is a big post, so don’t rush to get back. I know you’re busy, and I appreciate all the help you’ve already generously given to me.

Ohh, I almost forgot two important things...

4. Installing cgi-lib.pl in the readme file writes the following:

In Reply To
Download cgi-lib.pl if you don't have it. Place it in the same directory with quirex.cgi and set its permission to 755.

The problem is quirex.cgi isn’t the script I’m working with, I’m testing Guestex.cgi.

Do you think this is a readme file error?

Also,

5. Setting permissions in the readme file writes the following:

In Reply To
Upload all the files. Set their permissions as shown below:
chmod 755 guestex.cgi
guestex.pl

chmod 666 guestex.dat

chmod 644 header.txt
footer.txt
record.txt

The problem here is the readme file doesn’t tell me what directory to put these files in.
Also, there are more files involved with this Guestbook - HTML and GIF files, but I’m not told where to place them.
==================================================
SERVER SIDE INCLUDES


In Reply To
What you are trying to do sounds to me as if you should use frames in your HTML.

I’m quite familiar with frames and have tested with them several times in the past. I’m not a big fan of them. They would not suit my sites needs. I believe I can heavily benefit with the actions of SSI. However, thanks for the frames suggestion. I’m glad you mention everything that’s on your mind, because that way you’ll be able to understand thoroughly what the person your writing to is looking for. You’re very astute!

Do you know of any SSI forums?

Thanks,
Jenny



mhx
Enthusiast / Moderator

Jul 4, 2001, 10:57 AM

Post #122 of 123 (7335 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

let's go directly to the options in your configuration file. I assume you have the gifs uploaded to www/guestex/ and all the other stuff (except for the html's) to cgi-bin/guestex/.
I'm quite sure one of the problems - if not the only one - is the paths in your config file. Either, you should use just the following:

Code
#################################### 
# Path to the core part of Guestex, guestex.pl
$guestex = "guestex.pl";

####################################
# Path to the data file
$guestdata = "guestex.dat";

####################################
# Path to the HTML header
$header = "header.txt";

####################################
# Path to the HTML footer
$footer = "footer.txt";

####################################
# Path to the Record template
$rec_temp = "record.txt";

or the full server paths (as you recall from an earlier post):

Code
#################################### 
# Path to the core part of Guestex, guestex.pl
$guestex = "/home/ wherever /cgi-bin/guestex/guestex.pl";

####################################
# Path to the data file
$guestdata = "/home/ wherever /cgi-bin/guestex/guestex.dat";

####################################
# Path to the HTML header
$header = "/home/ wherever /cgi-bin/guestex/header.txt";

####################################
# Path to the HTML footer
$footer = "/home/ wherever /cgi-bin/guestex/footer.txt";

####################################
# Path to the Record template
$rec_temp = "/home/ wherever /cgi-bin/guestex/record.txt";

After adjusting this, the script should work. At least this should be a better basis to search for other errors...

In Reply To
The problem is quirex.cgi isn’t the script I’m working with, I’m testing Guestex.cgi.
Do you think this is a readme file error?

Yes I think the author just left some copy/paste text unchanged here. As I just see your writing of guestex.cgi, always be sure the case of the file names is correct when uploading. It's normally best to keep everything in lowercase. While this doesn't matter if you use Windows, it matters after uploading to a Unix server. Wrong/mixed case may also cause severe errors.

In Reply To
The problem here is the readme file doesn’t tell me what directory to put these files in.
Also, there are more files involved with this Guestbook - HTML and GIF files, but I’m not told where to place them.

I've put a note at the top where I assume those files were placed.

Bye,
Marcus



JennyW
journeyman

Jul 7, 2001, 3:20 PM

Post #123 of 123 (7317 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus-hx!

In Reply To
As I just see your writing of guestex.cgi, always be sure the case of the file names is correct when uploading. It's normally best to keep everything in lowercase. While this doesn't matter if you use Windows, it matters after uploading to a Unix server. Wrong/mixed case may also cause severe errors.

Ok, I’ll start from the top!

I changed the case of all of my files (except the one html file – test.html) before I uploaded. The reason I changed the case was for the following reasons:

1. Netfirms.com writes the following on their website…


In Reply To
You must place all your html and image files in the 'www' directory. Only files placed in the 'www' directory can be viewed on your website. Keep all filenames in lowercase characters. Your main page should be called index.html or index.htm.The webserver first looks for index.html and if not there it looks for index.htm

2. My guestex files were written like this when unzipped and viewed on a Windows platform:

Guestex.cgi
Header.txt
Header.txt etc. etc.

3. And the funny thing is when I viewed those same files in WSFTP they looked like this…

GUESTEX.CGI
HEADER.TXT
HEADER.TXT etc. etc.

4. So, any files that had capital letters I changed to small caps, since Netfirms asks files to be in lower case…

guestex.cgi
header.txt
header.txt etc. etc.

With the above file names (small caps) I made the adjustments you recommended in your last post, my tests were unsuccessful.

So, I thought – let’s start from the beginning! I erased everything and unzipped the .zip file again, BUT this time I left the file names at there original state (with capital letters: #2 and #3 - above).


In Reply To
let's go directly to the options in your configuration file. I assume you have the gifs uploaded to www/guestex/ and all the other stuff (except for the html's) to cgi-bin/guestex/.
I'm quite sure one of the problems - if not the only one - is the paths in your config file. Either, you should use just the following:

####################################
# Path to the core part of Guestex, guestex.pl
$guestex = "guestex.pl";


or the full server paths (as you recall from an earlier post):
####################################
# Path to the core part of Guestex, guestex.pl
$guestex = "/home/ wherever /cgi-bin/guestex/guestex.pl";

After adjusting this, the script should work. At least this should be a better basis to search for other errors...

Ok, so as I wrote, without making adjustments to the file names, I tested the two options you recommended in your last post), but I was still unsuccessful.

I’m stumped?


Below is a list of all of my files. I placed them in the following directories (I made guestex directories in the www and cgi-bin directories):

cgi-bin/guestex

Guestex.cgi
Guestex.dat
Guestex.pl
Footer.txt
Header.txt
Record.txt

www/guestex

test.html
Ball.gif
Ballhalf.gif

In my last post I thought I had to access this file to view my guestbook…

http://jennyw4.netfirms.com/cgi-bin/guestex/GUESTEX.CGI

But later I learned that I should be using this file, at least I think I should, I’m kinda confused.

http://jennyw4.netfirms.com/guestex/test.html

But when I access the url above and click submit I receive the GUESTEX.CGI link and then I get this message:


In Reply To
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, Your Webmaster and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

I don’t even know if I should be accessing test.html?

The readme file tells me to test the script like this, but I don’t know what it means?


In Reply To
- You can view the guestbook with the URL
http://www.mysite.com/cgi-bin/guestex.cgi?page
where page is the page number

Here’s the full readme file:

http://jennyw4.netfirms.com/guestex/for_viewing_only/readme.html

Here’s my path to my cgi-scripts in my test.html file:


Code
<form action="http://jennyw4.netfirms.com/cgi-bin/guestex/GUESTEX.CGI" method=post>

You can view my source at: http://jennyw4.netfirms.com/guestex/test.html

Here are my cgi-scripts:

http://jennyw4.netfirms.com/guestex/for_viewing_only/Guestex.cgi.txt

http://jennyw4.netfirms.com/guestex/for_viewing_only/Guestex.pl.txt

Here’s the original Guestex.cgi file, without my modifications:

http://jennyw4.netfirms.com/guestex/for_viewing_only/guestex_original.txt


I can’t seem to figure out what’s going on. What do you think?

Thanks,
Jenny


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives