Solved

uuencode problem with perl on hpux

Posted on 2003-11-12
5
1,207 Views
Last Modified: 2008-01-09
First, I have read through a number of previous posts here about uuencode and perl. As soon as I finish writting this, I'm going to explore MIME::Lite ,  but I'm curious as to the problem I'm having with uuencode right now.


 Now keep in mind that I'm having to work with HPUX 11i and perl 5.005_03 (long story about not upgrading) and I'm still relatively new to perl.
I have a text file generated out of some previous sql/perl mix.  Lets call it  dataout.txt.
The gist of the problem is this:
outside of perl, I can use the following code    uuencode dataout.txt dataout.txt  | mailx -s "extracted data" email.to@sendto.company.com
and it works fine.

However, when I use either of the following in a perl script:

system(`uuencode dataout.txt dataout.txt | mail "email.to\@sendto.company.com"`);
or
exec("uuencode dataout.txt dataout.txt | mail email.to\@sendto.company.com");

I still get an email with an attachement, but the attachment does not contain the data as it does if I use the same command from the unix command line.

As a 4 year old likes to say,  "Why?" .

Thank you in advance!

Mark Nelson
0
Comment
Question by:Mark_Nelson
  • 3
  • 2
5 Comments
 
LVL 20

Expert Comment

by:jmcg
ID: 9733166
You've changed two things at once, so it's hard to say which of the two is responsible for the problem. Outside of perl, you used the 'mailx' mailer, which is old and primitive, but still has a few smarts about internet mail. Inside of perl, you were using the 'mail' (sometimes known as 'binmail') mailer, an even older and more primitive mailer.

What happens if you use mailx from Perl?

Is it that the attachment is not there at all, is it empty, or is it simply not being recognized as an attachment by the recipient's mailer?

MIME::Lite is a better way to do this.
0
 

Author Comment

by:Mark_Nelson
ID: 9733255
jmcg;

The same thing happens if mail or mailx is used.

Actually, the email comes with an attachment of the proper name but a zero byte lengtht.
This is a text message and needs to come as an attachment, not in the body of the message.

I'm futzing with MIME::Lite now.  Just got the package installed and typed out a test script that failed ;).

Mark
0
 
LVL 20

Accepted Solution

by:
jmcg earned 50 total points
ID: 9733379
I'm afraid all I can tell you is that piping uuencode directly into mailx (or mail) will place the encoded lines in the body of the message. Neither mailer sets a proper MIME header specifying Content-Type or boundaries. Some mail programs recognize this old way of sending binary files and fix things up so it _looks like_ there's an attachment, but it's not really following the MIME structure.

To create a MIME message you need to use a mailer that a) understands how to handle an attachment (mutt and, I think, some versions of pine allow you specify a file for an attachment as a command-line option) or b) allows you to specify all of the relevant mail headers as part of the input (such as when mailing via "sendmail -t" or "qmail-inject").

MIME::Lite should do everything correctly as far as setting up the mail message. It still can be tricky to get the mail posted if there are restrictions on using the default methods that MIME::Lite knows about.

But I don't see why you should be getting different results from running the same command line with "system" or "exec" in Perl.
0
 

Author Comment

by:Mark_Nelson
ID: 9766067
as a final note to this saga, I was never able to get PERL to properly send the txt file as an attachment.
I tried the system(`uuencode.......)
I tried MIME::Lite as well.

However, when I wraped PERL in KSH and called the PERL code to do the data manipulation, then when it was done, return to KSH, I was able to get KSH to run the uuncode line just fine.

Shrug
:)

Mark Nelson
0
 
LVL 20

Expert Comment

by:jmcg
ID: 9766178
Sometimes a problem takes too long to solve and you gotta get by with something that you realize is makeshift, but it _works_.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now