简体   繁体   English

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

[英]No such file or directory: exec of '/opt/lampp/cgi-bin/ failed PERL XAMPP Ubuntu

When I am running my CGI Perl script I am getting an error. 当我运行CGI Perl脚本时,出现错误。

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

I am using XAMPP on linux enviroment and this file exists in the root folder. 我在Linux环境上使用XAMPP,并且此文件位于根文件夹中。

My Code:- 我的代码:

#!/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();

PLease help Thanks in advance!!! 请帮助提前谢谢!!!

1/ The error message seems self-explanatory. 1 /错误消息似乎不言自明。 It says that the file doesn't exist in '/opt/lampp/cgi-bin/'. 它说该文件在“ / opt / lampp / cgi-bin /”中不存在。 You say that the file is in the root directory. 您说该文件位于根目录中。 It's probably just a question of moving the file to the correct directory. 可能只是将文件移到正确目录的问题。

2/ You are loading CGI.pm, but not using any of its features. 2 /您正在加载CGI.pm,但未使用其任何功能。 Either use it (a good idea) or remove it. 使用它(一个好主意)或删除它。

3/ Once you get this file executing, you'll get the same "void context" errors as you mentioned in your previous question . 3 /一旦执行此文件,您将得到与上一个问题中提到的相同的“无效上下文”错误。 We showed you how to fix that over there too. 我们还向您展示了如何解决该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM