Replace A File From Email Attachment

I am looking for a method that would allow me to replace an existing file with one from an email attachment. Any way of scripting this, so when an email comes in from a particular email id, it takes the attached file, and replaces an existing file.

So, you need to receive mail, discard/set aside if not from ID or no attachment, extract the attachment and in the process overwrite a former file?

Sometimes it is better to delet the old file and write a new one, for programs that have the old file open.

You need a script-friendly attachment-capable email client. Perhaps PERL has libraries that support this.

If the email structure is pretty constant, you can find the attachment and extract it with common shell tools like sed or awk, and maybe a decoder like base-64. Take an email apart in vi and see.

Thank you, that's what I was thinking. My situation is this. We are working with SAP transports. And we might get an email request to send some transports. Instead of logging onto the SAP server, modifying the transport list file. We would like to send an email with a text file attachment that replaces this file. Eliminating the need to find a laptop/computer to logon on. Sending an email from a Crackberry or other phone would be so much easier.

So, you want to provide a service by email. Cool! Authentication is an issue, especially as email service is in plain sight. Have you considered a secure web service? With an email based service, you take on a lot of overhead tasks and risk.

You need to verify by successful extraction that it is a properly formatted request including return address and authentication, run the service and return an email with the service name and parameters listed and the results. If results are a table, CSV might be an easy mime type to attach.

---------- Post updated at 10:42 AM ---------- Previous update was at 10:39 AM ----------

We gotta pick one chain here!

Haven't thought about a webservice, might have to look at that. The email solution was the easiest one we could think of. Authentication wouldn't be a problem, since this server is behind a DMZ and would only be receiving mail from our exchange servers.

Yes, but anyone on the inside can send a mail and get at the data, and the firewall and mail server better not leak emails.

Some places do not like data running on the network in the raw, either. SSH is free, for login, cpy, ftp, on web servers, as tunnels or for other services.

I suppose you might devise a service where the incoming requests come with an id and that selects a password for some sort of locked file. zip has a password feature, but as I recall it is easily circumvented. Think how simple https is, off the shelf.

I work in a pretty secure environment, and only a few people would know what email address we would be using. So I don't think security would be a problem.