The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

Cat and inetd...help? by Kickstart2005-08-16 10:42:05
  cat isn't getting the file argument by pyroteknix2005-08-16 10:53:54
    Further strangeness by Kickstart2005-08-16 10:59:22
      Missing a Content-Type? by pyroteknix2005-08-16 11:01:29
        Here's a sample by Kickstart2005-08-16 11:02:49
          Give me a few... by pyroteknix2005-08-16 11:13:37
            I've got some of that... by Kickstart2006-11-19 12:55:59
              Oh. Heh. by pyroteknix2005-08-16 11:21:06
                I wonder about improving reportsock.pl by Kickstart2005-08-16 11:25:42
                  OK, Here's what I have so far. by pyroteknix2005-08-16 11:51:23
                    OK got it. by pyroteknix 2005-08-16 12:08:42
Silly wrong slash problem. I added the file size too, while I was at it. It seems to work fine with all the browsers I've tried here. Same caveats as the last post.
#!/usr/bin/perl
$|=1;

my $file = shift;
if(!$file) {
 # Needs sanity checking, but this is just a quickie
 print 'Usage: '.$0." <file>\n";
 exit;
}

# Wait for HTTP request to finish
my $in_line = '';
while($in_line ne "\r\n") {
 $in_line = <STDIN>;
}

# Load file
my $file_data = '';
open(REPORT_FILE, $file);
while(<REPORT_FILE>) { $file_data .= $_; }
close(REPORT_FILE);
my $file_size = length($file_data);

# Send HTTP response headers
print <<"END_HEADERS";
HTTP/1.1 200 OK
Server: reportsock/1.0 16aug2005
Content-Type: text/plain; charset=iso-8859-1
Date: Tue, 16 Aug 2005 18:14:23 GMT
Last-Modified: Tue, 16 Aug 2005 18:14:23 GMT
Accept-Ranges: bytes
Connection: close
Content-Length: $file_size
Cache-Control: max-age=0
Expires: Tue, 16 Aug 2005 18:14:23 GMT

END_HEADERS

# Send file
print $file_data;

exit 0;

Let me know if it works for you.

pyro

[ Reply ]
                      Heh, now we need to merge yours and mine :) (n/t) by Kickstart2005-08-16 12:14:47
                        Like this? by pyroteknix2005-08-16 12:26:46
                          That's funnny :) by Kickstart2005-08-16 12:34:55

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)