codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Adding header to each standard output  devine123 at 21:27 on Sunday, September 09, 2007
 

Hi, I’m creating a perl script that takes incoming http/s requests, logs the standard input, output and error, before returning the output to the client. The input, output and error log is appended after each HTTP request.

The problem I’m having is that I’m trying to add a header line to the log files each time they are appended. For example if a new http request is made, a header will be added to each of the logs before the new standard data is added. This will most likely contain the “$date” and “$time” to enable the user to locate their most recent http request in the logs.

I am unsure how to add this header before the STDERR, STDIN and STDOUT are sent to their corresponding logs. Can anyone point me in the right direction? Any help would be much appreciated. Thanks.

****************************************************************
#!/usr/local/bin/perl -w
use CGI qw(:standard);
use Cwd;

#Get the current date & time
($Second, $Minute, $Hour, $Day, $Month, $Year) = localtime(time);
$Year += 1900;
$Month++;
$date = "$Day.$Month.$Year";
$time = "$Hour:$Minute:$Second";

#Send the standard Error, Input and teed output to a log file
open (STDERR, ">> /tmp/$date-error.log") or die "can't connect to error.log: $!";
open (STDIN, ">> /tmp/$date-input.log") or die "can't connect to input.log: $!";
open (STDOUT, "| tee -a /tmp/$date-output3.log") or die "Can't connect to output.log: $!";

#Get the current working directory
$cgi_dir = getcwd();

# Serve the user
$result = system($cgi_dir . "/test-cgi");
exit $result;

#Close the standard output, input and error
close(STDERR) or die "Can't close error: $!\n";
close(STDIN) or die "Can't close input: $!\n";
close(STDOUT) or die "Can't close output: $!\n";
****************************************************************









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Re: repaint() slow performence..
•  To match on current line and the next line using perl?
•  Re: Text wrapping on C# webforms buttons
•  Increment revison when same item number
•  Re: Internet explorer doesnt load img on div
•  finger print reader?????
•  Re: How to concatenate a string and a variable using perl?
•  Re: questions on java
•  Frusturating loop


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007