Operating System - HP-UX
1752689 Members
5469 Online
108789 Solutions
New Discussion юеВ

Re: Get the attachment then ftp it ..

 
SOLVED
Go to solution
someone_4
Honored Contributor

Get the attachment then ftp it ..

Hey everyone,
Is there a script or a command to get an attachment from an email or several emails and put the attachments in one folder? I am running HPUX 11.0 and the attachments are coming from a windows box type email IE Outlook or Outlook Express. Here is my situation we have customer who send us .vox files for a custom prompts for an IVR.They email them to us and we have to manually ftp them to the IVRS, which are sco boxes. My idea is to have them email it to a username on an HPUX box (witch is already set up to receive and relay mail). Once the file gets to the HPUX box have a cron script that will extract the file and put it in a directory. Then have another cron script that will ftp or rcp the vox files to all the IVRs on the network. Everything is already set up on the network side. But my first step is to extract the attachment to a directory. The ftp script part shouldn?t be too hard.

Thanks,
Richard
9 REPLIES 9
Robin Wakefield
Honored Contributor

Re: Get the attachment then ftp it ..

Hi,

If you get them to send the mail with the attachment uuencoded (and gzipped, say) for example, to an address which is aliased to a program, then this could do the extraction for you, e.g. send to the user "extract" - in your aliases file, you'll have:

extract "|/usr/local/bin/read_att.sh"

/usr/local/bin/read_att.sh could contain something like:

=====================
#!/bin/ksh
/usr/bin/uudecode -p | gunzip -c > /tmp/att.$$
...
your ftp code
...


=====================

Rgds, Robin.
Lasse Knudsen
Esteemed Contributor

Re: Get the attachment then ftp it ..

You might want to take a look at some email extraction tools. You might want to take a look at the Software Porting and Archive Center for HP-UX. It seems that they have got some tools that will solve the extraction problem.
http://hpux.tn.tudelft.nl/hppd/hpux/Networking/Mail/alpha.html

Use it together with Robin's suggestion (uudecode is probably not enough).

/Allan
In a world without fences - who needs Gates ?
someone_4
Honored Contributor

Re: Get the attachment then ftp it ..

Hello
I downloaded ripmime of the porting website.
But I cant get it to work. I did
swinstall -s ripmime-0.1.11-sd-11.00.depot
For somereason I just cant get anything to work off this website.

Thanks
Richard
Lasse Knudsen
Esteemed Contributor

Re: Get the attachment then ftp it ..

What does "not work" mean ?

/Allan
In a world without fences - who needs Gates ?
Lasse Knudsen
Esteemed Contributor

Re: Get the attachment then ftp it ..

For some reason '-s' on swinstall requires full path to the depot file.

Is this what "not work" means ?

/Allan
In a world without fences - who needs Gates ?
A.E.Smit
New Member

Re: Get the attachment then ftp it ..

We had the same problem, we set-up a linux-box which gets mail from an exchange-server. On the linux-box we use procmail to start a Perl-script which cuts of the attachment of the mail and send this attachment to another system, using ftp. We also use the same system to create mail with attachment from a data-file and a e-mail adres. Also automated.

So we are able to send and receive mail with attachment automated.

There are Perl-modules available which do the attachment cutting.

Perl and procmail is availble on HP-UX, but you need to build your scripting, our scripting is about 1000 lines of scripting. Using shell-scripting will do the job, but i think you need more lines of code to get it up and running.

:-)
Allan
Gregory Fruth
Esteemed Contributor

Re: Get the attachment then ftp it ..

If the attachments are in MIME format, you
can use Perl's MIME::Parser to detach them.
You can then use Perl's Net::FTP to ftp them.

# read MIME message from stdin; save
# attachments to dir somedir
use MIME::Parser;
$p = new MIME::Parser;
$p->output_dir("somedir");
$e = $p->read(\*STDIN);

# ftp a file from somedir to destdir at remote host
use Net::FTP;
$ftp = Net::FTP->new("somehost.com");
$ftp->login("anonymous",'me@here.there');
$ftp->cwd("destdir");
$ftp->put("somedir/some.file");
$ftp->quit;

HTH
someone_4
Honored Contributor

Re: Get the attachment then ftp it ..

Hey Greg
thanks for the perl script.
I dont know anything about perl but it is a goal of mine to learn perl. Can you explain to me how to set that script up? We do have perl on out HP box so that is not a problem.
THanks

Richard
Robin Wakefield
Honored Contributor
Solution

Re: Get the attachment then ftp it ..

Richard,

Make sure you have perl V5 (run perl -v). If you have, create your executable script with the path to your perl binary at the top, e.g. #!/opt/perl5/bin/perl

If the MIME module is missing (just create a one line script containing 'use MIME::Parser;' to check), have a look at http://www.cpan.org to download it. Obviously this goes for any other missing modules.

A start, hopefully...Robin