【问题标题】:No such file or directory: exec of '/opt/lampp/cgi-bin/ failed PERL XAMPP Ubuntu没有这样的文件或目录: '/opt/lampp/cgi-bin/ 的执行失败 PERL XAMPP Ubuntu
【发布时间】:2014-01-12 13:23:41
【问题描述】:

当我运行我的 CGI Perl 脚本时,我遇到了一个错误。

No such file or directory: exec of '/opt/lampp/cgi-bin/filename.cgi failed

我在 linux 环境中使用 XAMPP,这个文件存在于根文件夹中。

我的代码:-

#!/usr/bin/perl
use diagnostics;
use DBI;
use strict;
use warnings;
use CGI qw(:standard);

my $driver = "mysql"; 
my $database = "mysql";
my $dsn = "DBI:$driver:database=$database";
my $userid = "root";
my $password = "password";
my $dbh = DBI->connect("dbi:mysql:dbname=mysql", "root", "password",
    { AutoCommit => 0,RaiseError => 1}, ) 
    or die ("Couldn't connect to database: ") , $DBI::errstr;

my $sth = $dbh->prepare("select * from userrecords");
$sth->execute();

print "Content-type:text/html\r\n\r\n";
print "<a href='/Index.html'>-> Home Page</a>";
print "<table style='border-style: double; width: 30%;' border='1' cellpadding='1' cellspacing='1'>\n";
print "<td style='font-weight: bold' align='center'>Name</td><td style='font-weight: bold' align='center'>Address</td>
<td style='font-weight: bold' align='center'>City</td><td style='font-weight: bold'    align='center'>Occupation</td><td style='font-weight: bold' align='center'>Age</td>\n"; 
while(my($ID,$name,$address,$city,$occupation,$age) = $sth->fetchrow_array) {
    print "  <tr>\n";
    print "    <td>$name</td>\n";
    print "    <td>$address</td>\n";
    print "    <td>$city</td>\n";
    print "    <td>$occupation</td>\n";
    print "    <td>$age</td>\n";
    print " </tr>\n";
 }  
print "</table>\n";
$sth->finish();
$dbh->disconnect();

请帮忙 提前谢谢!!!

【问题讨论】:

  • 这看起来像一个 apache/xampp 错误,所以也许你应该添加这些标签。当然,它看起来就像网络服务器在您所说的位置找不到您的filename.cgi。所以也许检查一下?

标签: linux perl ubuntu cgi dbi


【解决方案1】:

1/ 错误消息似乎不言自明。它说该文件在“/opt/lampp/cgi-bin/”中不存在。你说文件在根目录下。这可能只是将文件移动到正确目录的问题。

2/ 您正在加载 CGI.pm,但没有使用它的任何功能。使用它(一个好主意)或删除它。

3/ 一旦你执行了这个文件,你将得到与your previous question 中提到的相同的“无效上下文”错误。我们也向您展示了如何解决该问题。

【讨论】:

    猜你喜欢
    • 2015-08-05
    • 2018-12-17
    • 2023-03-17
    • 2020-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-09
    • 2011-04-08
    相关资源
    最近更新 更多