Perl 5.8 and MD5

J

Joe

I have been having trouble running some of my Perl scripts that use
Perl 5.6 using a Win 2000 server on 5.8a Win 2003 Server. It took
quite awhile, but I am 99.999999% sure I figured out it is the <b>MD5</
b> module.

Every time I remark it out, my scrfipt works. But, the script was
written to use MD5. I use the following line to call it:

<b><code>use Digest::MD5 qw(md5_hex);</code></b>

Is there any advice you can give, like, how to see what modules are
installed, to be sure it is?

Any help would be appreciated.
 
P

Paul Lalli

I have been having trouble running some of my Perl scripts that use
Perl 5.6 using a Win 2000 server on 5.8a Win 2003 Server. It took
quite awhile, but I am 99.999999% sure I figured out it is the <b>MD5</
b> module.

Every time I remark it out, my scrfipt works. But, the script was
written to use MD5. I use the following line to call it:

<b><code>use Digest::MD5 qw(md5_hex);</code></b>

This is a text only newsgroup. Why are you posting this fragment in
HTML?
Is there any advice you can give, like, how to see what modules are
installed, to be sure it is?

$ perldoc -q installed
Found in /opt2/Perl5_8_4/lib/perl5/5.8.4/pod/perlfaq3.pod
How do I find which modules are installed on my system?


Paul Lalli
 
A

all mail refused

Every time I remark it out, my scrfipt works. But, the script was
written to use MD5. I use the following line to call it:

<b><code>use Digest::MD5 qw(md5_hex);</code></b>

Is there any advice you can give, like, how to see what modules are
installed, to be sure it is?

The perl docs show how to use eval() when testing a module.

eval "use Digest::MD5 qw(md5_hex)";
if ($@) {
# ouch - better do something else...
}
 
J

Joe

eval "use Digest::MD5 qw(md5_hex)";
if ($@) {
# ouch - better do something else...
}

Sorry, about html code, wasn't sure if it would work, now I know it
doesn't.

Anyway, using eval, gave me an error of:

Content-type: text/html

'C:\Inetpub\wwwroot\cgi-bin\TestMD5.pl' script produced no output

I also did print "# ouch - better do something else... " in the if.

Does that mean the module is bad?
 
B

Brian McCauley

Sorry, about html code, wasn't sure if it would work, now I know it
doesn't.

Anyway, using eval, gave me an error of:

Content-type: text/html

'C:\Inetpub\wwwroot\cgi-bin\TestMD5.pl' script produced no output

I also did print "# ouch - better do something else... " in the if.

Does that mean the module is bad?

No, it looks like you are bad.

You are bad for not telling us what you are really doing.

That error looks like something a web server program might say. I'd
guess it might be Microsoft IIS.

There was no web server mentioned in your original question.

Going back to your original question when you "have been having
trouble running" some of your Perl scripts could you say how that
trouble was manifest? In particular what errors were printed, logged
or whatever.

BTW: do you have any reason to believe Digest::MD5 is installed?
 
J

J. Gleixner

Sorry, about html code, wasn't sure if it would work, now I know it
doesn't.

Anyway, using eval, gave me an error of:

Content-type: text/html

What? The example code you provided doesn't have anything
that would produce that line. If that line is displayed
in your browser, your Web server isn't configured correctly.
'C:\Inetpub\wwwroot\cgi-bin\TestMD5.pl' script produced no output

I also did print "# ouch - better do something else... " in the if.

Does that mean the module is bad?

No, otherwise you might have seen "# ouch - better do something else".

Why not read the documentation to see what eval actually does, instead
of blindly typing it in?

perldoc -f eval

Looks like your server isn't set up to run CGI correctly or something
is wrong with your script. Either post a short and complete example,
or work with your Web server's administrator to set it up correctly.
 
J

Joe

This the the smallest, I have:

01. #!/usr/bin/perl
02.
03. #Libarry file that will read the form data and store in
formdata{'value'} form
04. require '../lib/forminput.lib';
05.
06. &FormInput;
07.
08. print "HTTP/1.0 200 OK\n" if ($ENV{PERLXS} eq "PerlIS");
09. print "Content-Type: text/html\n\n";
10.
11. use Digest::MD5 qw(md5_hex);
12.
13. print qq(<html><head><title>MD5 Encryption</title></head><body>);
14.
15. if ($formdata{'flag'} eq "1") {
16. print qq(
17. Encryption
18. <br />
19. <br />
20. $formdata{'toEncrypt'} = );
21.
22. print md5_hex($formdata{'toEncrypt'})
23.
24. }
25. else {
26.
27. print qq(
28. <form action="md5.cgi?flag=1" method="post">
29. Text to Encrypt: <input type="text" name="toEncrypt">
30. <br />
31. <br />
32. <input type="submit" value="Encrypt">
33. </form>
34. );
35. }
36. print qq(</body></html>);

It runs fine on a Server (Win 2000) with Perl 5.6 installed. It will
not run with a server (Win 2003) and Perl 5.8 installed.

The error message I get is:
Content-type: text/html

'C:\Inetpub\wwwroot\cgi-bin\md5\md5.cgi' script produced no output.

It uses the MD5 module to encrypt a string, (password) in hex. Also,
I read the docs I was able to find on eval, and it says it runs what
is has, like a small program. So,, if it does not work, then
something is wrong with the Module?
 
J

Joe

Here is the revided script using strict with no line numbers

#!/usr/bin/perl

use Digest::MD5 qw(md5_hex);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser); # Module for
sending error message to browser.
use CGI qw:)standard :html3); # Module for using HTML Code
use strict;

#Libarry file that will read the form data and store in
formdata{'value'} form
require '../lib/forminput.lib';

&FormInput;

my %formdata;

print "HTTP/1.0 200 OK\n" if ($ENV{PERLXS} eq "PerlIS");
print "Content-Type: text/html\n\n";

print qq(<html><head><title>MD5 Encryption</title></head><body>);

if ($formdata{'flag'} eq "1") {
print qq(
Encryption
<br />
<br />
$formdata{'toEncrypt'} = );

print md5_hex($formdata{'toEncrypt'})

}
else {

print qq(
<form action="md5.cgi?flag=1" method="post">
Text to Encrypt: <input type="text" name="toEncrypt">
<br />
<br />
<input type="submit" value="Encrypt">

</form>
);

}

print qq(</body></html>);

Also, this program was written by someone else, I normally use
strict. The &FormInput input is from that person writing, it never
seemed to bother the programs I would modify, so I left 'em in.
Formdata is like using param(). And, YES, I did take it out, wioth
the library line, and it made no difference at all.

Even with the additions I still get the "script produced no output".

The program is run but going here: http://gailbapps/cgi-bin/md5/md5.cgi

Gailbapps is our Win 2003 Sever that has Perl 5.8 installed on it. I
am reading thru that link that was sent to me now.
 
J

Joe

I ran it from the cmd line, with the use diagnostics; line for that
page, and in the Perl log, I get:

PerlParse did not exit clean! I tried looking that up through google,
and it lead me to MD5 last week.
 
M

Mumia W.

Here is the revided script using strict with no line numbers

#!/usr/bin/perl

use Digest::MD5 qw(md5_hex);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser); # Module for
sending error message to browser.
use CGI qw:)standard :html3); # Module for using HTML Code
use strict;

#Libarry file that will read the form data and store in
formdata{'value'} form
require '../lib/forminput.lib';

&FormInput;

my %formdata;
[...]

This line creates a new lexical variable named formdata that hides the
old variable formdata that had been created by forminput.lib. Do this
instead:

our %formdata;

It's good you posted a somewhat complete program to test. In the process
of trying to get your program to work, I discovered this.

For more good ideas for getting good help out of this newsgroup, read
the posting guidelines:

http://www.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html

BTW, it's spelled "library."
 
J

J. Gleixner

Joe said:
I ran it from the cmd line, with the use diagnostics; line for that
page, and in the Perl log, I get:

PerlParse did not exit clean! I tried looking that up through google,
and it lead me to MD5 last week.

Look through your forminput.lib.
 
J

J. Gleixner

Joe said:
Here is the revided script using strict with no line numbers

#!/usr/bin/perl

use Digest::MD5 qw(md5_hex);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser); # Module for
sending error message to browser.
use CGI qw:)standard :html3);

Why aren't you using the methods available to you?

perldoc CGI
Also, this program was written by someone else, I normally use
strict.

Then maybe 'someone else' should help you.

The &FormInput input is from that person writing, it never
seemed to bother the programs I would modify, so I left 'em in.
Formdata is like using param(). And, YES, I did take it out, wioth
the library line, and it made no difference at all.

Even with the additions I still get the "script produced no output".

Then start with a basic script.. e.g.

% cat mytest.cgi.
#!/usr/bin/perl
use CGI qw( :standard );
print header, start_html( 'testing' ), p('does this work?'), end_html;


If that works, then add a line or two at a time. If it doesn't
then you need to figure out how to configure your Web server
correctly.
 
J

Joe

I don't want to make excuses, but, the 'someone else' who wrote some
of the scripts that do not work died in a motorcycle accident about a
year back who was never big on documentation, a cardianl sin I know.
Also, Perl was installed by our Network Administrator with that
persons help. When I ask the Network Admin about it, I get a 'I Don't
Know' I get the run around about reinstalling, but he says NO.

I just need some, possible, hints on how to do this that may work. I
have no idea how to configure a web server, but, this is where my
understanding lacks alot. I am a Help Desk/Programmer who just writes
what I am told too..everything has been in place from the get go for
me.

If anyone knows a way for me to explain how to reconfigure Perl to
work with MD5, I'm all eyes and ears. I am told not to touch Servers,
it is not my job. I just write and maintain programs on them.
 
R

Ron Bergin

Here is the revided script using strict with no line numbers

#!/usr/bin/perl

use Digest::MD5 qw(md5_hex);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser); # Module for
sending error message to browser.
use CGI qw:)standard :html3); # Module for using HTML Code
Why do you load the CGI module, but never use it?
use strict;

#Libarry file that will read the form data and store in
formdata{'value'} form
require '../lib/forminput.lib';

&FormInput;

my %formdata;

Get rid of that library, I'm sure it's using outdated and poorly
written code, and instead use the methods provided by the CGI module.

#!/usr/bin/perl

use strict;
use CGI;
use Digest::MD5 qw(md5_hex);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser); # used while
debugging

my $cgi = CGI->new;
my %formdata = $cgi->Vars;
print "HTTP/1.0 200 OK\n" if ($ENV{PERLXS} eq "PerlIS");
print "Content-Type: text/html\n\n";

print qq(<html><head><title>MD5 Encryption</title></head><body>);

I say again, use the CGI module.

print $cgi->header, $cgi->start_html('MD5 Encryption');
warningsToBrowser(1);
if ($formdata{'flag'} eq "1") {
print qq(
Encryption
<br />
<br />
$formdata{'toEncrypt'} = );

print md5_hex($formdata{'toEncrypt'})

}

else {

print qq(
<form action="md5.cgi?flag=1" method="post">
Text to Encrypt: <input type="text" name="toEncrypt">
<br />
<br />
<input type="submit" value="Encrypt">

</form>
);

}

print qq(</body></html>);

Instead of me rewriting your script for you, you should read the
documentation for the CGI module.
http://search.cpan.org/~lds/CGI.pm-3.29/CGI.pm
 
R

Ron Bergin

If anyone knows a way for me to explain how to reconfigure Perl to
work with MD5, I'm all eyes and ears. I am told not to touch Servers,
it is not my job. I just write and maintain programs on them.

Paul already provided the info ( which was perldoc -q installed ) that
points to the documentation on how find out what modules are
installed, buts here's an example on how to test if the Digest::MD5
module is installed.

Executed from the command line:

perl -MDigest::MD5 -e 1

If you don't receive any output, then that means that the module is
installed.

If you receive an error message telling you that it can't find the
module, then either it's not installed, or it may have been
incorrectly installed.
 
R

Ron Bergin

[snip]

use the methods provided by the CGI module.

#!/usr/bin/perl

use strict;
use CGI;
use Digest::MD5 qw(md5_hex);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser); # used while
debugging
I noticed that I forgot 1 module.

use warnings;
 
A

all mail refused

I don't want to make excuses, but, the 'someone else' who wrote some
of the scripts that do not work died in a motorcycle accident about a
year back who was never big on documentation, a cardianl sin I know.
Also, Perl was installed by our Network Administrator with that
persons help. When I ask the Network Admin about it, I get a 'I Don't
Know' I get the run around about reinstalling, but he says NO.

I just need some, possible, hints on how to do this that may work. I
have no idea how to configure a web server, but, this is where my

There's always the option of telling the boss you can't do it and asking
him to give the task to someone else. If not overused it works fine.
 
R

Ron Bergin

If anyone knows a way for me to explain how to reconfigure Perl to
work with MD5, I'm all eyes and ears. I am told not to touch Servers,
it is not my job. I just write and maintain programs on them.

Paul already provided info that points to the documentation on how
find out what modules are installed, buts here's an example on how to
test if the Digest::MD5 module is installed.

Executed from the command line:

perl -MDigest::MD5 -e 1

If you don't receive any output, then that means that the module is
installed.

If you receive an error message telling you that it can't find the
module, then either it's not installed, or it may have been
incorrectly installed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,735
Latest member
HikmatRamazanov

Latest Threads

Top