Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
Showing results for 
Search instead for 
Did you mean: 

elm and uuencode script

Go to solution

elm and uuencode script

ok, this is going to be a bit difficult to describe.
any quotes in this message are not part of actual commands, but rather to convey meaning.
I have a canned erp application.
(assume HPLJ printer is set up in UX correctly)
When I set up printers withing the application, we define printer HPLJ and also put in a string "lp -onb -dHPLJ" (with no quotes.
You run a report from erp app and it prints no problem.
I have now set up a printer called EMAIL with a string "elm -s "Report" $LOGNAME
Now the user gets the report in the body of a message via email.
So to me it looks like the erp app is basically adding "< reportdata" when producing output.
What I want to achieve is sending "reportdata" as an attachment.
I know this for sure(file test is text with "hello" in it).
from ux prompt
(uuencode test test.txt) | elm -s test will send an email with a subject of test and an attachment of test.txt
So, understanding that the erp app seems to add < "reportdata" to the string i enter.
Is it possible to have a unix script that I could enter into erp app that would take < "reportdata" directed to it and email it to the user as an attachment?
Clear as mud?
Will assign points for solutions!!
Honored Contributor

Re: elm and uuencode script

You can try something like this...

# vi /usr/local/bin/
while read INPUT
echo $INPUT
) >> /tmp/output
ux2dos /tmp/output > /tmp/final
uuencode /tmp/final output.txt | sendmail
rm /tmp/final /tmp/output

In your ERP Application

Define "/usr/local/bin/" as the string

Above script is not necessarily the best/elegant way to do it, especially if the reportdata is huge in size.

Wait for other suggestions from our forum folks :-)
Learn What to do ,How to do and more importantly When to do ?

Re: elm and uuencode script

My experience with elm (somewhat old) is:
When you use elm interactively, it is possible to send an attachment. However when you use elm from command line, this does not work. A solution I can think of is using Expect, which will pretend as if user is interacting with elm even though it is non-interactive.
A. Clay Stephenson
Acclaimed Contributor

Re: elm and uuencode script

Elm will work just fine from the command line and it's quite easy BUT you must make certain that there is a .elm directory in the sender's home directory. Elm invoked interactively will create the .elm directory automatically but elm under the command line will fail if .elm does does exist.

Within the body of your email add this:


This is my text. How are you?

[include /tmp/myattach application/octet-stream base64]

This is some more text in the middle.

[include /tmp/myexcel.xls application/ms-excel base64]

This is a closing message in the email.


That will attach the files "/tmp/myattach" and "/tmp/myexcel.xls" with the text of your message. If the above textfile were /tmp/my.text then you would do this:

cat /tmp/my.txt | elm -s "My Subject"

to send your message along the the two files as attachments.

If it ain't broke, I can fix that.

Re: elm and uuencode script

Thank you all for the responses.
Sundar seems to understand and have the best idea so far ..... but I have not tried it yet.
I understand what you are saying Clay, but as I tried to describe, the output is generated by the erp app and files do not exist on disk(except as they are spooling), so there is no editing of files.
I have tried to describe it as best as I can and I think the solution is going to be along the lines of what Sundar is suggesting.
Clay, could you give my origional post another read over.
All I have to work with is a script that has < "erp generated report" directed to it. < "erp generated report"
Will assign points for solutions!!
Sridhar Bhaskarla
Honored Contributor

Re: elm and uuencode script

Hi Daniel,

Let me see if I understood your message.

Put the following line in a script say ''

uuencode your_report |mailx -m -s "reportdata"

If you run the command < reportdata

You should get reportdata as an attachment called "your_report" with the subject "reportdata".

-m is important otherwise you will get the whole thing as a body.


You may be disappointed if you fail, but you are doomed if you don't try