Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

beginner question

Posted on 1998-09-24
2
Medium Priority
?
156 Views
Last Modified: 2013-12-25
I try to use a counter in my HTML page, but it doesn't
work...

I use this script PERL :
--[BEGIN - counter.pl]---------------------------
#!/usr/local/bin/perl -s


$filename="./counter.txt";


if (!open(COUNTER, "$filename"))
  {
    print "couldn't open for read\n;"
  }

else
  {
    $count=<COUNTER>;
    close (COUNTER);
   
    if ($count =~ /\n$/)
      {
      chop($count);
      }
  }

$count++;



if(!open(COUNTER, ">$filename"))
  {
    print "couldn't open for print\n";
  }
else
  {
    print COUNTER "$count";
    close (COUNTER);
  }

print "$count";

--[END - counter.pl]---------------------------
and I use a JavaScript function in my HTML file :

counter(<!C-#exec cgi="/cgi-bin/counter.pl")

this function work fine if I write
counter(23) for exemple. My counter is well display 23.
But when I try with the CGI bellow : Nothing appears !!!

Note, I use CERN HTTP Server on Solaris
0
Comment
Question by:baresse
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Author Comment

by:baresse
ID: 1828782
Edited text of question
0
 
LVL 5

Accepted Solution

by:
b2pi earned 40 total points
ID: 1828783
If I understand you properly, this works fine from the command line,
yet seems to fail when called via the java script?

See that line

$filename="./counter.txt";


??  Well, what is '.' when you're running from the server?  Do you
have write rights? Can you create a file there?  Does the file already
exist? [Hint: Specify the absolute path of the file].

By the way, when you're printing from the script, where does the
output go? [More hints: it goes to never never land].

Try this

open(COUNTER, $filename)
    || die "Content-type: text/html\nUnable to open file: $!";


Also, try running

perldoc chomp

to see a better way of getting around that if statement in the middle
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question