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 pyroteknix 2005-08-16 11:51:23
Mind you, this is just quick code, a better perl hacker (LionsPhil?) should probably have a look at it.
#!/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>;
}

# 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
Cache-Control: max-age=0
Expires: Tue, 16 Aug 2005 18:14:23 GMT

END_HEADERS

# Send file
open(REPORT_FILE, $file);
while(<REPORT_FILE>) { print; }
close(REPORT_FILE);

exit 0;
Just replace /bin/cat in inetd.conf with whatever you save this as (make sure you chmod +x it ;)

It seems to work fine with most browsers, and IE gets the output. The funky think is that IE is echoing the headers, rather than using them. If I remove the headers, it only gets the file, but then the default text/html type takes over and makes it ugly.

I'll work on it a bit more.

pyro

[ Reply ]
                    bah.. s/funky think/funky thing/ (n/t) by pyroteknix2005-08-16 11:52:02
                    OK got it. by pyroteknix2005-08-16 12:08:42
                      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
                    Some cleanup... by Kickstart2005-08-16 12:14:00
                      Yup. by pyroteknix2005-08-16 12:15:48
                        No worried...thanks very much! (n/t) by Kickstart2005-08-16 12:16:25
                          No problem ;) by pyroteknix2005-08-16 12:27:38
                            Absolutely by Kickstart2005-08-16 12:36:00

 

[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.)