Computing.Net > Forums > Unix > Parsing and emailing a text file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Parsing and emailing a text file

Reply to Message Icon

Name: Ed K
Date: December 11, 2004 at 10:12:49 Pacific
OS: WIN XP SP2
CPU/Ram: PIV 1500/256 megs
Comment:

I have a customer with SCO Unix and Windows . He has is a program that can create a large textfile. What he will use this program for is to create a text file that will contain a large amount of customer statements. How it will be parsed is up to us. He wants to run a program that will read thru the text file and email the statements.
We are in the how in the hell do we want to do this stage. This is going to take some decent string manipulation and parsing. seperating the header from the the detail lines each detail line from one another and individual statements from each other . Then sending the email so that hopefully each statement arrives at correct customer and the statement is readable.
We have little experiance in unix programming. This looks like a one time deal.
So what we need is way to do this that has the quickest learning curve. Would it be C,awk,other or even a Windows method(I know blasphomy on this board)



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: December 11, 2004 at 12:17:16 Pacific
Reply:

You really don't say where the text file is created - SCO or Windows. You also don't mention whether you are able to email from SCO easily.

I would hate to parse any file using C, and I'm a fair C programmer. I'd rather use Unix tools.

Of course, the best tools are the ones you have expertise with. If it's a one time deal you might consider hiring a contractor.

Regards,

Nails


0

Response Number 2
Name: Ed K
Date: December 11, 2004 at 13:20:35 Pacific
Reply:

I still do not know a lot of information about how he creates this file. I have been just told he has a tool to create it. But an ASCII file should be the same in both and he has the ability to copy the file between systems.
Our tools are prehistoric and will have to deal with the Unix or Windows tools anyway. I am communicating with a newsgroup about that. But I just need the basics on the unix tools


0

Response Number 3
Name: nails
Date: December 11, 2004 at 14:50:57 Pacific
Reply:

Ed:

IMO, If you don't have sendmail working on SCO Unix, it's probably going to be easier to do the emailing from windows?

If you want to email me a copy of your spec, I'll be glad to give you an opinion.

Your choice.

Nails


0

Response Number 4
Name: FishMonger
Date: December 11, 2004 at 15:46:10 Pacific
Reply:

Perl (Practical Extraction and Reporting Language) would be the perfect tool for this task. It was originaly designed for (but not limited to) text processing. Once it parses the file, it can open a SMTP connection to your mail server and send all emails (without the need for sendmail).

Perl is probably already installed on the SCO system, but if not, it can easily be installed on either SCO or Windows.

http://cpan.org/ports/index.html

No matter which tool you decide on, we'd need to see the format and sample contents of the text file.


0

Response Number 5
Name: Ed K
Date: December 15, 2004 at 13:05:11 Pacific
Reply:

I have a lot more information on what my customer is trying to do.
He has SCO 5.05. He has UUCP but no SendMail. He is creating the ASCII text files thru the DBL language.
He wants to have one program do many things. One day he may want to do as I said above type in customer statements and email them the statements. The next day he would want to use the program to choose type in a invitation to the company Christmas bash and email them to 5 people.
Can this be done thru DBL? If not what language would be good. Would it be a good idea to convert the text to HTML or PDF?.


0

Related Posts

See More



Response Number 6
Name: nails
Date: December 16, 2004 at 15:37:57 Pacific
Reply:

So, the ASCII files are created with DBL. From what I understand, DBL is a proprietory language similar to COBOL. I seriously doubt you're going to find anybody familiar with DBL - even if your customer has a DBL compiler/interpreter.

I'd use the standard unix tools, like grep, awk,perl to parse the files. How big are the text files? That could take time.

Converting the text to HTML or PDF depends on how you want to deliver the final product to the people being emailed.

UUCP stands for Unix-to-Unix Copy and it's old. Maybe somebody has come up with a way to use it to copy from SCO to windows, but I'm not aware of it.

Bottom line: It sounds like your customer wants a fairly flexible program and so you're not going to do it with a 3 line unix shell script. It also sounds like it's straining the resources of your system.



0

Response Number 7
Name: Ed K
Date: December 16, 2004 at 16:53:45 Pacific
Reply:

New information and another question. As I said above I found out that the customer has SendMail on a Linux Mail Server that the Unix Box connects to.
Somebody on another board said he uses Splitmail to send invoices out to different customers. Seems similar to what I want. Any problems with that program?


0

Response Number 8
Name: cbishop
Date: December 20, 2004 at 08:44:27 Pacific
Reply:

i'm trying to parse a text file as well,
and i'm open to using perl, though i've
been experimenting with a bash script
using gawk. my scenario is as follows.

objective .. mail new passwords to users
username password file generated in the format of
username1 password
username2 password
username3 password etc..

a distribution list is parsed one line at a time.
it is in the format of ...
username1 user1@okccc.edu
username2 user2@okccc.edu
username3 user3@okccc.edu

username and email address are assigned to variables.
a grep is performed on the password file with the
username variable as it's arguement. the output is
piped to gawk which returns the password string.
grep user passwdfile | gawk '{ print $2 }'

password string is sent via sendmail to the user's
email address. the 2 textfiles could optionally
be merged into one 3 column file.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Parsing and emailing a text file

Print certain line from a text file www.computing.net/answers/unix/print-certain-line-from-a-text-file/6955.html

Remove blanks from a text file www.computing.net/answers/unix/remove-blanks-from-a-text-file/6582.html

How to detect EOF of a text file www.computing.net/answers/unix/how-to-detect-eof-of-a-text-file/5111.html