• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 269
  • Last Modified:

SSI in html page fail to execute (counter script , etc)

I have an html page calling for execution of a counter script like so:
<!--#exec cgi="../cgi-bin/counter.cgi"-->
The script works when executed directly in the browser as counter.cgi, but not when called from the page.

I've configured the Netscape Enterprise 4.1 SP12 web server on my Solaris 8 v 2/02 Sparc20 to activate server-parsed html with the exec tag and to parse all html files from the doc root on down.

There are 3 files involved: a counter data file which increments when the script is executed, the script itself and the html page which calls it.  The permissions are 745 for the web page, 755 for the cgi, and 666 for the data file.

The error I get inside the web page is:[an error occurred while processing this directive]

I've tried other SSI, like including a random quotes script, or a date, these all work on another server running Apache but not with Netscape.  I can't switch to Apache right now, I'm supposed to stick with our baseline and find something that works.  I'd really like to know why this won't work, and the fix for it.  

Here's the cgi script:
#!/usr/bin/perl -wT
use CGI;
#use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use Fcntl qw(:flock);

$countfile = "counter";

$cgi = CGI->new;
print $cgi->header;

if (-e $countfile) {
     open(OUT, $countfile) or &dienice ("Couldn't open file: $!");
     flock(OUT, LOCK_EX);
     seek(OUT, 0,0);   #go to the beginning of the file
     $count = <OUT>;   #read one line
     close(OUT);
     $count = $count +1  #increment the counter
     }
     else {
     $count =  1;
     }

open(OUT,">$countfile") or &dienice("Couldn't open file: $!");
     flock(OUT, LOCK_EX);
     print OUT "$count\n";
     close(OUT);

     print "You are visitor number $count.";

sub dienice {
     my($errmsg) =  @_;
     print $errmsg;
     exit;
     }

What's incredibly frustrating (other than this should be a lot more simple than I have found it to be) is that I can't even diagnose the problem, since the script runs from the command line and the web server error logs show nothing.

Thanks,
Christine



0
klukac
Asked:
klukac
  • 3
  • 2
1 Solution
 
klukacAuthor Commented:
I'm not sure where this question belongs, Applications or Programming are probably more appropriate than Solaris, however when I tried to edit the question, changing the category didn't show up as an option.  
0
 
killerwhackCommented:
This could be several things.  The first thing that jumps at me is the relative path in the exec tag.  If I recall correctly that relative file paths are not allowed (for security reasons)

0
 
killerwhackCommented:
Another thing it could be: the syntax of the exec tag-

<!--#exec cmd="/main/script.cgi" -->

0
 
killerwhackCommented:
look in the errors log file to, perhaps, see more information as to why the ssi failed.
0
 
klukacAuthor Commented:
This has been bugging me for a long time, thanks very much!
I tried the path from root, which didn't work, but finally got a response from the web server.  The error logs showed root twice in the path.  So getting rid of the .. in the relative path was the key.  
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now