简体   繁体   中英

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.

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.

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. It says that the file doesn't exist in '/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. 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 . We showed you how to fix that over there too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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