CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Here's another one...more involved



Jan 22, 2001, 11:07 AM

Post #1 of 5 (421 views)
Here's another one...more involved Can't Post

The following code works great on my NT box but not on mt hosts Apache Unix box. All it does is scan the specified folder for a list of filenames and displays the files as links in a 2 column table. When the script is run on the Unix box I get an error message that there was a problem executing the directive.

Any help would be apprechiated.

Sean Shrum

Code follows:


# Split the name-value pairs from the query string
@pairs = split(/&/, $ENV{'QUERY_STRING'});
foreach (@pairs){
($name, $value) = split(/=/, $_);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$input{$name} = $value;

# open the user specified directory
opendir (DIR, "$input{'path'}") or die "Error opening the specified directory: $input{'path'} $!\n";;

# get all the filenames in the directory minus the '.', '..','.*'
@filenames = grep { $_ ne '.' and $_ ne '..' and $_ ne '_vti_cnf' } readdir DIR;

# close the directory

# increment the number of filenames by 1
$numberoffiles = $#filenames + 1;

print "<table align=center><tr><td align=center><font size=6><b>Contents of '$ENV{'SERVER_NAME'}/$input{'path'}'</b></font></td></tr><tr><td align=center><font size=\"2\">$numberoffiles files currently housed in this folder</font></td></tr><tr><td> </td></tr>";

# display the filenames as links in a table
print "<table width = 100% border=0><tr>";

# display the filenames in a table
foreach (sort @filenames) {
print "<td align=center><a href=\"/$input{'path'}/$_\">$_</a></td>";
if ( $count % 2 ) {
print "</tr><tr>";
print "</table>";


Jan 22, 2001, 11:46 AM

Post #2 of 5 (418 views)
Re: Here's another one...more involved [In reply to] Can't Post

My guess is you're not able to open the directory like you're trying to. Check the error log.

Jeff "japhy" Pinyan -- accomplished hacker, teacher, lecturer, and author


Jan 22, 2001, 4:34 PM

Post #3 of 5 (411 views)
Re: Here's another one...more involved [In reply to] Can't Post

I checked the log after producing the error short:

invalid CGI ref "/cgi-bin/" in /a/home/shrum/docs/soaring/photos/index.shtml

I check the perlguru archive and found another person with the problem but I am already doing the SSI call correctly in the page:

<!--#exec cgi="/cgi-bin/"-->

Any ideas?

Thanx again for all your help.

Sean Shrum

User / Moderator

Jan 22, 2001, 8:54 PM

Post #4 of 5 (404 views)
Re: Here's another one...more involved [In reply to] Can't Post

"but I am already doing the SSI call correctly"

Unfortunately you are not. Let us borrow from Section 5.7 of the Mouse book (CGI Programming on the World Wide Web)...

Remember we talked about query strings as a way of passing information to a CGI program in Chapter 2? 
Unfortunately, you cannot pass query information as part
of an SSI exec cgi directive. For example, you cannot do the following:

<!--#exec cgi="/cgi-bin/"-->

But the book does provide a way out...

However, we can create a regular Perl program (not a CGI program) that takes a date as an argument, 
and calculates the number of days until/since that date:

<!--#exec cmd="/usr/local/bin/httpd_1.4.2/ 4/1/96"-->

In the Perl script, we can access this command-line data (i.e., "4/1/96") through the @ARGV array.

It seems a major oversight in the rules for SSI, but it is what we have to live with.

Sun Sep 9, 2001 - 1:46:40 GMT, a very special second in the epoch. How will you celebrate?


Jan 23, 2001, 1:19 PM

Post #5 of 5 (380 views)
Re: Here's another one...more involved [In reply to] Can't Post

Is this issue inheirent only on Unix or is it that NT is more lenient? As I stated before, the SSI calls works beautifully on my NT intranet box.

Thanx for the info.

Sean Shrum

Sean Shrum
<a href=""></a>


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives