Replace A File From Email Attachment


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Replace A File From Email Attachment
# 1  
Old 03-08-2013
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.
# 2  
Old 03-08-2013
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.
# 3  
Old 03-11-2013
Quote:
Originally Posted by DGPickett
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.
# 4  
Old 03-11-2013
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!
# 5  
Old 03-20-2013
Quote:
Originally Posted by DGPickett
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.
# 6  
Old 03-20-2013
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.

Last edited by DGPickett; 03-20-2013 at 03:32 PM..
# 7  
Old 03-20-2013
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Cronjob output to file AND to email (as attachment)

I have a shell script that runs on our webserver logs, and grabs various useful data and then outputs this data to a .csv file. What I want to do now is schedule a cronjob to run this script for me each week at a designated time, AND email the .csv file that is created as an attachment to... (1 Reply)
Discussion started by: xdawg
1 Replies

2. Shell Programming and Scripting

Email with .dat file as attachment

Hi, I am trying to email a .dat file as an attachment from unix MS-outlook. I tried uuencode but it is not attaching the file, rather it is placing some junk data in the body of mail. Below is my code (cat Message.txt; uuencode Attach_File.DAT Attch_File.DAT) | mailx -s "SUBJECT"... (12 Replies)
Discussion started by: sampoorna
12 Replies

3. Linux

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. (4 Replies)
Discussion started by: evencustard
4 Replies

4. Shell Programming and Scripting

Sending a file as an attachment to email

The file is located under appl/batchdata/ file name: storesales.txt I am using following code because uuencode is not present. I am not getting the data in file but i am getting the blank file with same name as an email attachment. ( echo "from: sch@xxxx.com" echo "to:sch@xxxx.com" echo... (2 Replies)
Discussion started by: skatpally
2 Replies

5. UNIX for Advanced & Expert Users

email file as attachment...

Hello all, i am on hp-ux 11.23...i am trying to send an email as an attachement but it dose not seem to work...after reading on google i found that we can use uuencode to send file at attachement...here is my file and the syntax $ cat test.txt NAME --------- TEST $ uuencode... (7 Replies)
Discussion started by: abdul.irfan2
7 Replies

6. Shell Programming and Scripting

Send a file through email using cron as an attachment

Hi All, I want to send a file as an attachment through cron job.Is this possible using cronjob nd if it i, can you please let me know how to do this? Thanks (2 Replies)
Discussion started by: NARESH1302
2 Replies

7. Shell Programming and Scripting

Sending email and attachment file using Perl

I am trying to send an email body of information and also attachment using perl script, but I am only able to send the body but not an attachment. is there around it without using "use MIME::Lite;" module. $user = "bataf\@xyz.com"; $subjectt = "mail from perl"; open(MAIL, "| mailx -s... (1 Reply)
Discussion started by: bataf
1 Replies

8. Shell Programming and Scripting

UNIX file attachment in email

Hi, I have a syntax for mail attachment as $EMAIL "Wrapper $wrapper_script_name has failed" " $wrapper_script_name has Failed " $failed_email_address and $EMAIL is as below MSGSub=${1} MSGText=${2} RMAIL=${3} #set LANG='' export LANG='' echo "${MSGSub}" | mailx -s "${MSGText}" ... (1 Reply)
Discussion started by: satgur
1 Replies

9. How do I send email?

Transfering unix file as an email attachment

I've written a a script which generates a report file, saved to a unix directory. I need to transfer it, via email, to some users. The command I'm using in my script is: (note that subject & cur_address are set in the script prior to this line) cat /u/sandyl/sm_o_commdt_archive/c | uuencode... (3 Replies)
Discussion started by: slivi
3 Replies

10. UNIX for Dummies Questions & Answers

Transfering unix file as an email attachment

I've written a a script which generates a report file, saved to a unix directory. I need to transfer it, via email, to some users. The command I'm using in my script is: (note that subject & cur_address are set in the script prior to this line) cat /u/sandyl/sm_o_commdt_archive/c | uuencode... (3 Replies)
Discussion started by: slivi
3 Replies
Login or Register to Ask a Question