SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: perl on NT

  1. #1
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have been trying to make a simple feedback form for NT. I tried asp and looking for free scripts but they didn't work right. So I decided I would write my own script. I'm getting this error when I run it however.

    The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:


    Could not open Log File. at C:\InetPub\wwwroot\cgi-bin\comments.pl line 6.


    I dont know why its doing this. The script basically recieves form input, prints it to a file, and then prints a welcome page.

    Now line 6 is where the filehandle is opened:

    open (FILEHANDLE, "book.htm") or die "Could not open Log File.";

    and I have set the permissions for book.htm as read and exec for everyone. I dont know what the problem is, could someoneplease help?

    Chris

  2. #2
    Destiny Manager Plebius's Avatar
    Join Date
    Nov 1999
    Posts
    682
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    put this at the beginning:

    print "HTTP/1.1 200 OK\n";

    and use the full path to book.htm .

    [This message has been edited by LuZeR (edited February 28, 2000).]

  3. #3
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried that and i still isn't working. I dont get the header error anymore but now the script doesn't give the results I want it to. Example I want it to open or create a file and print to it the input from a form. It doesn't print or create the file. Then I want it to print a thank you message, and it does not print that either. Infact the only visible text on the resulting page is a <

    So anyways here is my entire script:

    #!c:\perl
    use CGI;
    $co = new CGI;
    print "HTTP/1.1 200 OK\n";
    print $co->header,
    $co->start_html(
    -title=>'Comments'
    );

    open (FILEHANDLE, ">C:\inetpub\wwwroot\cgi-bin\book.htm") or die "Could not open Log File.";

    $username = $co->param('NAME');

    $text = $co->param('MESSAGE');

    $company = $co->param('Company');

    $email = $co->param('email');
    print FILEHANDLE (

    "Comments by ", $username, " of ", $company,

    $text,

    "Response Email: ", $email
    ),

    close FILEHANDLE;

    print

    $co->center($co->h1('Thanks for your comments.')),

    $co->end_html;

    I can write a non cgi perl script and run it fine on my system so I dont think its anything to do with NT, maybe IIS though.

    Chris

  4. #4
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You need to have write permissions on your book.html file. Make sure that both the file and the directory are writable by the browser. If you don't have your own server you may have a specific data directory where you have to put your file for it to be accessible.

    ------------------
    Wayne Luke
    Internet Media Provider

  5. #5
    SitePoint Member
    Join Date
    Feb 2000
    Location
    Laguna Hills, CA, USA
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The below is wrong:

    open (FILEHANDLE, "book.htm") or die "Could not open Log File.";

    Try this

    open (FILEHANDLE, "book.htm") | | die print "Could not open Log File.";




  6. #6
    Destiny Manager Plebius's Avatar
    Join Date
    Nov 1999
    Posts
    682
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It wasn't wrong. 'or' and '| |' are the same thing in perl. If you add $! to the error message, it will tell you why it couldn't open the file. useful for troubleshooting.

  7. #7
    SitePoint Member
    Join Date
    Feb 2000
    Location
    Laguna Hills, CA, USA
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, I agree, the "or" and "| |" are the same thing. My addition was the "print" statment after the "or". You will also need to have an HTTP header, print "Content-type: text/html\n\n" printed prior to the error or the "print" statement will fail aswell.

  8. #8
    Destiny Manager Plebius's Avatar
    Join Date
    Nov 1999
    Posts
    682
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah, I didn't see the print statement.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •