Web Analytics Made Easy -
StatCounter Java Applet using Perl CGI to read/write to txt file - CodingForum

Announcement

Collapse
No announcement yet.

Java Applet using Perl CGI to read/write to txt file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Java Applet using Perl CGI to read/write to txt file

    Hi All,

    I've been trying to learn Perl to create a simple cgi script to read and write from a txt file.

    My Java portion is correct (I think) because when it tries to execute the script it gets a Code 500, which I believe means my cgi had a boo boo.

    I'm new to cgi, but this shouldn't be too difficult, right?
    For the record, I have set all files w/ permission 777 for now, and still this script crashes.

    #!usr/bin/perl

    print "content-type: text/plain\n\n";

    open(IN, "employee.txt");

    while(<IN>)
    {
    print $_;
    }

    close (IN);
    exit 0;

    I don't see any problems, I've been fiddling and searching for hours now.
    Could the problem be in my web server?

    Thanks for your time,
    Ben Barrett

  • #2
    Code:
    #!/usr/bin/perl
    
    print "content-type: text/plain\n\n";
    
    open(IN, "employee.txt") or die "Can't open employee.txt: $!";
    
    while(<IN>)
    {
    print $_;
    }
    
    close (IN);
    exit 0;

    Comment


    • #3
      An added comment/explaination to Kevin's suggestion.

      It doesn't matter which language your're using, you should ALWAYS check the return value of an open call to verify that it was successful.

      Comment

      Working...
      X