Change directory in CGI script

  • Tiradientes
  • Born
  • Born
  • Tiradientes
  • Posts: 1

Post 3+ Months Ago

I have what I think is a simple question: My cgi is in a directory called "bin". I want it to point to directory "Count" which is located here:
. . bin
. . data
Count
. . htdocs

I gather that it means rewriting the line
open(A, "<$ab[1]");
but I am not sure how to do this. The in-line code on the HTML pages is this:
<SCRIPT language="JavaScript"
SRC="[homepage]/bin/gcount.cgi?0=Site"></SCRIPT>
The full script is at the end of this message. I hope someone can be of assistance.

PERL Code: [ Select ]
#!/usr/local/bin/perl
# Change the line abve to match the path to perl on your server
#=========================================
# Copyright July 2002 All Rights Reserved
# By Brent Maurer.
#=========================================
# DON'T CHANGE ANYTHING AFTER THIS LINE
#=========================================
 
# INSTRUCTIONS FOR USE
# See accompanying README.TXT file.
 
 
use CGI;
$Arguments = $ENV{'QUERY_STRING'};
$LOCK_EX = 2;
$LOCK_UN = 8;
 
#print "Content-type: text/html\n\n";
print "Content-type: application/x-javascript\n";
print "Pragma: no-cache\n\n";
 
@ab = split(/=/, $Arguments);
 
$value=0;
 
unless (open(A, $ab[1]))
{
print "document.write(\'err\')\;";
die ("File not found $ab[1]");
}
 
close(A);
 
open(A, "<$ab[1]");
$value = <A>;
chomp($value);
 
$value += 1;
if ($value < $ab[0]) { $value = $ab[0]; }
 
#--------------------------------------------------------------------
sub comify{
my $text = reverse $_[0];
$text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
return scalar reverse $text;
}
#-----------------------------------------------------------
my $val = comify($value);
 
print "document.write(\'$val\')\;";
close(A);
 
open(A, ">$ab[1]");
flock (A, $LOCK_EX);
print A $value;
flock (A, $LOCK_UN);
close(A);
  1. #!/usr/local/bin/perl
  2. # Change the line abve to match the path to perl on your server
  3. #=========================================
  4. # Copyright July 2002 All Rights Reserved
  5. # By Brent Maurer.
  6. #=========================================
  7. # DON'T CHANGE ANYTHING AFTER THIS LINE
  8. #=========================================
  9.  
  10. # INSTRUCTIONS FOR USE
  11. # See accompanying README.TXT file.
  12.  
  13.  
  14. use CGI;
  15. $Arguments = $ENV{'QUERY_STRING'};
  16. $LOCK_EX = 2;
  17. $LOCK_UN = 8;
  18.  
  19. #print "Content-type: text/html\n\n";
  20. print "Content-type: application/x-javascript\n";
  21. print "Pragma: no-cache\n\n";
  22.  
  23. @ab = split(/=/, $Arguments);
  24.  
  25. $value=0;
  26.  
  27. unless (open(A, $ab[1]))
  28. {
  29. print "document.write(\'err\')\;";
  30. die ("File not found $ab[1]");
  31. }
  32.  
  33. close(A);
  34.  
  35. open(A, "<$ab[1]");
  36. $value = <A>;
  37. chomp($value);
  38.  
  39. $value += 1;
  40. if ($value < $ab[0]) { $value = $ab[0]; }
  41.  
  42. #--------------------------------------------------------------------
  43. sub comify{
  44. my $text = reverse $_[0];
  45. $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
  46. return scalar reverse $text;
  47. }
  48. #-----------------------------------------------------------
  49. my $val = comify($value);
  50.  
  51. print "document.write(\'$val\')\;";
  52. close(A);
  53.  
  54. open(A, ">$ab[1]");
  55. flock (A, $LOCK_EX);
  56. print A $value;
  57. flock (A, $LOCK_UN);
  58. close(A);

Post Information

  • Total Posts in this topic: 1 post
  • Users browsing this forum: No registered users and 105 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.