I am hoping to find out if it is possible to use some sort of UNIX programming/scripting tools to solve a problem I have with reformatting email messages that are sent out of my IBM UNIX (AIX) system. I'm thinking some advanced awk/sed may work
I do not have the time or the ability to do this work, if it's even possible. So if it is possible, I would be looking for someone to do the work for me.
I want to make sure I stay within the rules, so can you pleae advise the correct way to ask this in the forums or which forums I should use.
Thanks for the quick response. The email being sent is an automatic email that is sent when one of my order takers enters an order. The email that is sent includes all of the line items that are on the order and it looks like this:
(The formatting in this reply isn't quite working...), but essentially each line contains the Item Number, Description, Order Qty, Extended Price, Required Date and Line Disposition. The problem is that the alignment doesn't work because 'padding'/'leading spaces' have been removed by my software application, so the columns do not line up correctly.
So I would need to parse the fields in each line then somehow 'realign' them, possibly with a tab delimteter.
I hope that makes sense, if not, I can try to elaborate further.
The output is slightly too large for email (80 columns max recommended) but maybe you can take it from there.
Like the computer, we can only guess which fields are "Item" and which are "Desc"; the other parts may not be too hard to fix. If you know how many fields there are supposed to be and which may contain embedded spaces, maybe you can convert the spaces to something else before feeding the text to column, and convert back afterwards. Here's a proof of concept.
Last edited by era; 08-21-2008 at 12:21 AM..
Reason: Add proof of concept
Thanks for the suggestion, I thought something like this may be possible.
I do have the ability to put delimiters between the fields, I assume that would allow me to extract the fields in the correct place.
The much more difficult part of this is the fact that this information is being sent out as an email by my server. I need to reformat the data, then resend it out to an email address that is contained in another field in a different section of the email.
Lastly, there about 40 of these emails every hour that need to be parsed and 'resent' out.
Is it possible to build that sed code into some sort of routine that would do that process automatically when an email is received?
I do have the ability to put delimiters between the fields,
In this case it is even a lot easier to do it. One will not have to rely on these complicated heuristics era had to resort to in absence of delimiters (great job, btw., era) but could use simply "cut" to split every line into fields, then use "printf" to output the fields in a formatted way.
Suppose your delimiter will be "|" (the pipe symbol) then your file would look like (just header and one line):
The reformatting is quite easily done now by the "cut"-utility: cut reads a line of text (aka "records") and splits it up into "fields" using a separator character. I show the logic in ksh here because this is easier to understand, the same functionality could be done in awk but the resulting code would be less intuitive.
Quote:
The much more difficult part of this is the fact that this information is being sent out as an email by my server. I need to reformat the data, then resend it out to an email address that is contained in another field in a different section of the email.
Not at all difficult: suppose you have already extracted the adressing part and put it in variables:
How exactly the address and subject is to be extracted is depending on the form of the input file. Just give us an example and i am sure someone or other can work that one out.
Quote:
Lastly, there about 40 of these emails every hour that need to be parsed and 'resent' out.
This poses no problem. If there is a certain condition (for instance a file is produced by your software, etc.) to watch for the script i sketched out could run in a loop looking every x seconds for the condition to become true and than act accordingly, otherwise wait for another x seconds. 40 mails an hour should pose no problems even for the smallest p505 there is. The execution for such a script will typically take a fraction of a second.
I am trying to create a makefile to build a program and am getting the following error:
make -f tsimplex.mk
make: *** No rule to make target `/main/tsimplex_main.cpp', needed by `tsimplex_main.o'. Stop.
OPSYS = $(shell uname -s )
TARGET = tsimplex
ROOTDIR = ../../..
GTSDIR =... (1 Reply)
I have been trying to split up my src directory to clear out files that are not re-compiled very often. Now I have the following setup in my trunk,
trunk/bld
trunk/src/
trunk/src/src_server
trunk/makefile.linux
In the make file, I have compile rules
SOURCELOC = src
# compile src c++... (4 Replies)
Hi,
While installation of apache on linux, we perform the below tasks.
1) Untar
2) configure
3) make
4) make install.
I wanted to understand the difference and working of configure/make/make install.
Can any one help me understanding this?
Thanks in advance. (1 Reply)
hello all,
attached you can find a tool (written in C) that i really need to make it compile under linux
i am able to compile and run it successfully in mac os x, but in linux the compilation fails
the only thing that i did so far is to change the following
#include <sys/malloc.h> to... (13 Replies)
Discussion started by: OneDreamCloser
13 Replies
5. Post Here to Contact Site Administrators and Moderators
In light of this board's rule stating "no BSD vs. Linux vs. Windows or similar threads," is the following post legal (can I post it)?
Hi. I'm thinking about obtaining a web server for business purposes and I want to learn to administer and maintain the server myself. I need to be able to use... (1 Reply)
I attached a README file that I will refer to.
I successfully completed everything in the README file until step 4.
# pwd
/gani/gani-2.4.4
# ls
COPYING Makefile.macros gem.c
Makefile Makefile.sparc_gcc gem.h
Makefile.amd64_gcc ... (1 Reply)
Hi,
Recently I install a package and try to do a make and make install.
However, in the make it gives me below error:-
make:Nothing to be done for 'install-exec-am'
make:Nothing to be done for 'install-data-am'
Can anyone please explain to me what does this mean? I have been trying... (1 Reply)
Hi,
This stems from the following thread https://www.unix.com/showthread.php?t=18299
I have a makefile which makes either executables or a shared library.
i.e. make -f unix.mak will create the executables and
make -f unix.mak libolsv will create the shared library.
Since these have to be... (4 Replies)