home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

I have created an anonymous email script...

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 2104
Discussions: 200,919, Posts: 2,379,057, Members: 246,287
Old January 18th, 2003, 01:14 AM   Digg it!   #1 (permalink)
Junior Member
 
Join Date: Jan 2003
Posts: 1
I have created an anonymous email script...

I have created an anonymous email script...

I have a problem... I am currently logging the emails, but I would like to view them via another perl script that I have failed at doing. You can see the script in action at negativepulse.com.

Here is how it prints to the log from the initial email script.
Code:
 

$logmail = "1";
#
#----------
if ($logmail == 1) {
open(LOG, ">>BLAHsecretBLAH.txt") ||
flock(LOG, 2);
print LOG "---------------------------------- \n";
print LOG "Date: $date \n";
print LOG "IP: $ip \n";
print LOG "Referrer: $ref \n";
print LOG "Browser: $browser \n";
print LOG "User: $user \n";
print LOG "To: $FORM{'email'}\n";
print LOG "From: $FORM{'from'}\n";
print LOG "Subject: $FORM{'subject'}\n";
print LOG "Message: $FORM{'message'}\n";
flock(LOG, 8);
close(LOG);

}

#######
An example of the output is...

Code:
 ---------------------------------- 
Date: Wednesday, November 27, 2002 at 23:56:34 
IP: ***************
Referrer: ************
Browser: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) 
User:  
To: ***********
From: ************
Subject: ***********
Message: ******
Please help me code a script that reads this....
daza1 is offline   Reply With Quote
Old February 9th, 2003, 07:54 AM     #2 (permalink)
Not Really a Member
 
Join Date: Oct 2001
Posts: 25,382
have you tried using regular expressions?

I'm not entirely familiar with perl, but I've done other similar work. If you have a set format its much easier than a loose format where you dont' know exactly what to expect. Here you could look for specific text, find the position of it and find all the text after that text appears and stop at the end of the line.
For instance in vb you could do...

iDatePos = InStr(1, strLineToRead, "Date:")
iDateString = Mid(strLineToRead, iDatePos + 5, Len(strLineToRead))
I use iDatePos + 5 because you want to start at the end of Date: which is 5 chars... if you want to include that text just get rid of the +5...
Now to do that in perl I'm unsure but that may be at least the pseudocode to help ya out.

Welcome to TechIMO
__________________
Helicopters don't fly; they vibrate so much and make so much noise that the earth rejects them.
vass0922 is online now   Reply With Quote
Old February 13th, 2003, 05:03 AM     #3 (permalink)
Junior Member
 
Join Date: Feb 2003
Posts: 4
Try this:
code:

open (FILE, 'BLAHsecretBLAH.txt');
@lines = (<FILE>);
foreach $lines (@lines) {
print;
}

That will put the lines in an array that to Perl will have the string representation of what you printed to the file. So the array itself would look like kind of this very shortened version, if you defined it manually:
@lines = qw ("-------" , "Date: 12/2/02\n", "IP: $ip \n", "Referrer: $ref \n", "Browser: $browser \n", "User: $user \n", "To: $FORM{'email'}\n", "From: $FORM{'from'}\n", "Subject: $FORM'subject'}\n", "Message: $FORM{'message'}\n");

Of course all the variables above would be the actual data that the person entered when mailing you.

I hope that helps....
MiniPerl is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (2849)
Obama the Muslim (12)
Why is Khalid Sheikh Mohammed even .. (9)
Is the PSU I received dead? (10)
windows vista security holes (7)
Foreign voltage (10)
HIS HD5770 graphic card question (15)
Install XP pro and a Vista laptop ?.. (9)
Dept. of HS: NSA 'Helped' Develop V.. (15)
A good PSU? (10)
Print spooler problem (10)
New Computer wont recognize XP disc (7)
Ideal cheap graph card for PC-Gamin.. (15)
EVGA 9800 gtx help with finding a g.. (8)
Recent Discussions
Display shows 3x5 inch in middle of s.. (2)
[F@H SPAM 11/16/09] ! 1/2 months to r.. (33)
World's largest Monopoly Game using G.. (331)
Foreign voltage (10)
FiOS modem/router interfering with ne.. (7)
Browsers wont load websites (2)
Virus Doctor Popup? (1)
Help getting around port 80 for camer.. (1)
Dept. of HS: NSA 'Helped' Develop Vis.. (15)
windows vista security holes (7)
Install XP pro and a Vista laptop ?? (9)
EVGA 9800 gtx help with finding a goo.. (8)
Modern Warfare For the PC (32)
Problem with speed step/turbo boost? (1)
monitor will not turn on at all, (0)
Modern Warfare 2: Who Bought It? (61)
Print spooler problem (10)
SIS 740 and Widescreen (8)
Baffling Problem with my CPU/MoBo's. .. (0)
HIS HD5770 graphic card question (15)
Best file format to play on Windows H.. (0)
PSP Go bought in Japan (0)
Asus P4G8X Mobo (3)
Need hard disk drivers (4)
windows 7 internet problem (4)


All times are GMT -4. The time now is 07:16 PM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28