I've got a project written in classic asp, and a particular form's submit is handled by a Perl script.
I'm going to do an enhancement for this project. I installed the latest version of ActivePerl for Windows 32 bits.
I looked at the production environment and saw that in the IIS 7.5, there is an entry on "Handler Mappings" for *.pl to be handled by C:\Perl\bin\PerlEx30.dll. So I did the same thing on development environment. (please note that there is no mapping for "*.cgi" on the Prod. environment)
Now when I'm trying to submit the form which its action is MyScript.pl, I get the following error:
HTTP Error 405.0 - Method Not Allowed
The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.
Maybe worth saying that, I'm on 64 bits environment, I tried ActivePerl for Windows 64 bits as well (I mapped *.pl to perl514.dll) but still getting the same error!
Your workaround was to use 32-bit version of perl. If you want to use the 64-bit version, this worked for me on IIS 8.5 Windows 2012 R2:
Add Module Mapping to your site:
Request path: *.pl
Module: CgiModule
Executable: C:\Perl64\bin\perl.exe "%s" %s
Name: Perl CGI
You can test it by creating the following 'hello world' page:
use strict;
use CGI;
my $page = new CGI;
my $msg = "Hello from ActivePerl CGI!";
print $page->header( "text/html" ),$page->start_html( $msg );
print $page->h2($msg);
print $page->end_html;
Name it something like test.pl, drop it into your webroot directory and browse to it to test.
The application pool was set so "Enable 32-Bit Applications = false", I change it to true, and it fixes the issue.
You haven't said whether or not you've gotten ANY Perl to work yet (even a "hello world"), or if the problem is this one particular script (perhaps just on this one particular server).
ANYWAY -
I doubt your Perl install is the problem.
You definitely need to do more troubleshooting.
I'd start with verifying whether a simple, one-line "hello world" will work.
Next, I'd "divide and conquer" to determine exactly WHERE the problem is. I'm guessing it's very probably somewhere in "MyScript.pl". I'm also guessing that it should be fairly easy to track down.
These links might help give you more clues as to exactly what you might look for as you "divide and conquer" (AFTER you've verified that Perl itself can be invoked from your IIS):
What causes an HTTP 405 "invalid method (HTTP verb)" error when POSTing a form to PHP on IIS?
http://www.tech-faq.com/troubleshooting-iis.html
PS:
I'm guessing the problem might be as simple as a missing, or inappropriate, URL in "MyScript.pl"!
PPS:
At the risk of repeating myself - please verify "helo_world.pl" first. If it doesn't work, please post the complete "hello_world" script and the complete error message(s).
Related
I am trying to create a mail using Mail::Outlook. I followed this answers I believe is correct:
Sending email using Perl
Mail::Outlook CPAN
I created a simple code based from the tutorials:
use strict;
use warnings;
use Mail::Outlook;
use Data::Dumper;
my $outlook = new Mail::Outlook();
print Dumper($outlook);
print Dumper(Win32::OLE->LastError()); #added in response to comment
my $message = $outlook->create();
$message->To('sample#gmail.com');
$message->Cc('another#gmail.com');
$message->Subject('Testing sending mail from perl');
$message->Body('Hi, This is the body! wahahah!');
$message->save();
1;
The emails I used are real but I replaced it here for privacy's sake..
When I run the script, an error appeared:
$VAR1 = undef;
Can't call method "create" on an undefined value at send_mail.pl line 14.
It seems that the variable $outlook did not initialized during new Mail::Outlook(). The module Mail::Outlook returns undef if initiating a new object failed.. Now, I wonder why this happened.. I am thinking it was because of security issues of outlook but I don't know how to tweak that. Please perl masters out there, if anyone has the same experience or have encountered this, it would be helpful..
I am using Microsoft Outlook 2007 in windows 7 and I installed ppm install Mail-Outlook.
My main question is: How can I create a mail using Mail::Outlook in Outlook 2007
UPDATE
I tried using print Dumper(Win32::OLE->LastError()); and it printed this error:
$VAR1 = 'Win32::OLE(0.1709) error 0x80080005: "Server execution failed"';
After following what Tim Tom has instructed, with a little search, I saw an article about the error Win32::OLE(0.1709) error 0x80080005: "Server execution failed"
COM Process Elevation Mismatching
It says that the access level of the outlook application and perl script must be the same:
To make a long (and frustrating) story short, the problem was that I was running the script from a CMD.EXE window which was elevated (“Run as Administrator”). When I would run Outlook from a non elevated process (as a normal user would) there appeared to be a process elevation mismatch.
this is the same in my case.. I was running my cmd as Administrator while my outlook was running normally..
MSDN has a say to this:
COM security is aware of integrity levels and does not allow lower-integrity clients to bind to class instances running at a higher integrity level.
after changing my command line with the same elevation level as the outlook app, the perl script worked perfectly!
Note: perl crashes while using print Dumper(Win32::OLE->LastError()); if it has no errors..
We have a custom perl install (5.10.1) in /usr/share, and I tried to do a 'cpan -i' install of GeoIP2 here
After doing this, it seemed to install a lot of dependencies I couldn't keep track of, and since I've been getting an error
Subroutine IO::Socket::INET6::sockaddr_in6 redefined at /usr/share/perl5/Exporter.pm line 67
On most scripts that we run that uses a 'use' command. I've been trying to nail down which module eventually calls that, but not succeeded as yet.
After some research, one suggestion was to comment out the following lines of
/usr/share/perl5/IO/Socket/INET6.pm # (version 2.56, think latest is 2.72)
###commented out the following
###use Socket6 (
### qw(AI_PASSIVE inet_ntop inet_pton getaddrinfo
### sockaddr_in6 unpack_sockaddr_in6_all pack_sockaddr_in6_all)
###);
This has stopped the errors from appearing on various scripts. Does anyone know if this is safe to do (ie will it cause further problems later), and is there a better way to go (ie is it possible to just update that module, I'm guessing that would cause problems and break other stuff?). What would be the best method of getting the module updated correctly ?
This was a bug in IO::Socket::INET6 which was fixed in version 2.69 according to this bug report:
Subroutine main::sockaddr_in6 redefined at /usr/share/perl/5.14/Exporter.pm line 67.
...
Should be fixed in 2.69.
You can update the module using cpan with the command cpan IO::Socket::INET6 from the shell as root.
Easiest is just to stop using IO::Socket::INET6 at all. That was created a very long time ago, but a far better solution has been created using the core Socket module, being IO::Socket::IP. Furthermore, this latter module is now core also since the newly-released 5.20. it would be better to use that IO::Socket::IP as that is the new core-recommended way to achieve IPv4/IPv6 transparency from now on.
I've inherited some Perl code that runs on a Linux server just fine. I'm in the process of getting it to run on Windows XP, ActiveState Perl 5.16.2, and a BitNami WAMP stack. (Note: this setup is already running my Perl .cgi programs so this is a working setup.)
Anyway the "main" Perl program--let's call it main.cgi--has this statement:
require("extra/stuff_1.cgi");
When main.cgi runs, an error occurs:
C:/BitNami/apache2/cgi-bin/extra/stuff_1.cgi did not return a true value at C:/BitNami/apache2/cgi-bin/main.cgi line XX.
Now here's what is weird: stuff_1.cgi ends with 1; (i.e., it is the last line in the file)!
I've even commented out the code in the functions within stuff_1.cgi -- which are mostly functions with Here Documents, e.g.
sub func {
return <<EOF;
...
EOF
}
making it contain just
sub func {
#
#return <<EOF;
#...
#EOF
}
etc.
and yet the "did not return a true value" still occurs!
However if I delete all the code so stuff_1.cgi contains
1;
the error goes away (as it should).
stuff_1.cgi passes perl -c, even with use strict and use warnings
ETA: If I copy the contents of stuff_1.cgi and paste it into main.cgi (replacing the require statement), the code works just fine.
I've never seen anything like this before; what could possibly be the cause?
Why is the debugger not working (ActiveState or Strawberry Perl under Windows)?
Why is the debugger not working [ActiveState or Strawberry Perl under Windows]?
A recent release of PathTools (part of Perl distribution, file Cwd.pm) unfortunately contains a bug which breaks EPIC's debugger frontend. The specific symptom is the error message "perl5db.pl did not return a true value." - to see this message, you should enable the "debugger console" in EPIC Preferences. Furthermore, if you have this problem, debugging doesn't work at all. To fix it, you must edit Cwd.pm of your Perl distribution and remove the offending "eval" keyword from one line, as described in this bug report. DO NOT attempt to fix it by adding Perl's "lib" directory to your project's include path, as this will cause all breakpoints to be ignored!
Perhaps what I've encountered is a defect in ActiveState's version of Perl.
Anyway--after spending way too much time on this--the only way I could get it to work is by replacing
require 'extra\stuff_1.cgi';
with
eval { require 'extra\stuff_1.cgi' };
I dislike having to do this but it's time to move on!
I'm beginning to write a simple Perl program on my Mac, and I understand that the first line needs to be the location of Perl itself, every example or tutorial I find tells me the first line should be:
"#!/usr/bin/perl"
However, with that there, I attempt to run the file under localhost and I get this error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, you#example.com 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.
Anyone have any idea why this is happening?
Thanks in advance, and let me know if any more information is needed!
P.S. if it helps, when I execute the command: "perl -v" it tells me
This is perl, v5.10.0 built for darwin-thread-multi-2level
(with 2 registered patches, see perl -V for more detail)
As Erik said, /usr/bin/perl is the standard location for Perl on OSX. You can also verify this by running which -a perl from terminal (this will list all instances of Perl on your path).
Can you run your script from the command-line, i.e. ./<myscript>.pl? It's possible that you haven't made the script executable.
#!/usr/bin/perl is the correct path for 10.6. If you're running from the webserver, your first line before any output should be a HTML header. You may have forgotten one?
#!/usr/bin/perl
use CGI;
print CGI->header('text/html');
print "hello world";
I have a Web-based Perl Win32::OLE script that uses Excel on the server side. It has been working happily for years on a Win2000 server running Excel2000. We recently upgraded to Win2003/Excel2003 and I now get the following error from the script:
Win32::OLE(0.1709) error 0x80070005: "Access is denied" at create_worksheet_lib.plx line 639
eval {...} called at create_worksheet_lib.plx line 639
line 639 is:
$Excel = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;}) or die "Oops, cannot start Excel";
It appears that Perl no longer has access to Excel. Any Windows gurus out there that might be able to help trouble shoot this?
Seems like the same wicked problem described in another post, however, no solution found...
Maybe troubleshooting with Procmon will reveal where the problem lies (see http://support.microsoft.com/kb/286198).
Can you run the script from a command line on the server (taking the web server out of the mix)? That's the first thing I'd try. If it works from the command line then it's probably a permissions issue or a web server configuration issue.