没有这样的文件或目录:exec of'/ opt / lampp / cgi-bin / failed PERL XAMPP Ubuntu

时间:2014-01-12 13:23:42

标签: linux perl ubuntu cgi dbi

当我运行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();

提供帮助 在此先感谢!!!

1 个答案:

答案 0 :(得分:0)

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

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

3 /执行此文件后,您将获得与your previous question中提到的相同的“void context”错误。我们也向您展示了如何修复它。