Visit The New, Modern Unix Linux Community

<Mail> attachment param is not working under system function

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting <Mail> attachment param is not working under system function
# 1  
<Mail> attachment param is not working under system function

Hi Guys,

I have executed the mail command that has attachment with filename as current date enclosed in system function that is added under awk command.
I have used awk command to check if the error code is present in the file then email command sends an email with subject Error Code ,body provided in the file 'mailmessage.txt' and attachment of current date file .

awk '{if ($1 ~ /BIP8071I/)  {
DATE="`date '+%d%m%Y'`"
system("mail -s" $1 "test\\ "Information"\ emailid -a /home/test/abc_$DATE.txt <  /home/test/mailmessage.txt")

This command has executed without any flaws. But when I received the email, I didn't find the attachment . Instead, the -a parameter is coming in to section of the email box as provided in the attachment.
&lt;Mail&gt; attachment param is not working under system function-27th-oct-emailpng

Can anyone suggest if this can be possible in system function.


Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 10-29-2018 at 09:30 AM.. Reason: Added CODE tags.
# 2  
Welcome to the forum.

Please become accustomed to provide decent context info of your problem.

It is always helpful to carefully and detailedly phrase a request, and to support it with system info like OS, shell, and, here, mail version. Some mail command just don't provide the -a attachment option.

BTW, your awk script has syntax errors, so I'd be surprised if it "has executed without any flaws". The DATE variable won't be assigned as the date command won't be executed.
# 3  
Yes. You are right. When I tried to pass this file context as a body to the mail command before. I was getting error as file is not found like this :
FlowStats_.txt: No such file or directory

As well as even though, i have executed it as single line command as below :

DATE="`date '+%d%m%Y'`" mail -s"test" emailid -a /home/test/abc_$DATE.txt <  /home/test/mailmessage.txt

This was also not working.

I have also tried without parameter -a in the mail command. This is also not working.

Can you please provide the mail command that has attachment under system function.


------ Post updated at 01:51 PM ------

Hi Guys,

I can now able to send the attachment of current date file with the below command :
awk '{if ($1 ~ /BIP8071I/)  {
system("cat /home/test/mailmessage.txt|mail -s" $1 "test\\ "Information"\ -a /home/test/FlowStats_`date '+%d%m%Y'`.txt  emailid");


------ Post updated at 01:53 PM ------

I hope this helps .

Last edited by Scott; 10-31-2018 at 06:27 AM.. Reason: Please use CODE tags

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #626
Difficulty: Easy
False === 0.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sending an email with mail function shows up as an attachment 'noname'

I have a file named email.html with this as the contents: Content-type: text/html ACHI,ACCRETIVE HEALTH ,7.15,<br>CPRT,Copart Inc.,36.14,<br>GEOB.MX,GEO-B,1.660,<br>GCO,Genesco Inc. Comm,73.58,<br>GMAN,Gordmans Stores, ,<br>GES,Guess? Inc. Comm,26.45,<br>KBR,KBR Inc. Common... (1 Reply)
Discussion started by: phpchick
1 Replies

2. Shell Programming and Scripting

How to send mail using PHP mail function On apache server.?

Hello, I am using centos-6.2 I have apache server,php5 on my system and I want to send mail using sendmail on my system. when I try to send mail from shell that time mail is succesfully sent to respective address() but when I try to send it through webbrowser I am not able to send it.... (1 Reply)
Discussion started by: Kiran ursal
1 Replies

3. Shell Programming and Scripting

Mail Attachment Not Working for Cron

Hi All, i Have An Script Which is Fetching Data From DB And sending Mail With the Data in Excel Format. i'm Receiving Mail with Attachment when i Manually Running the script using ksh -x Scriptname or ./ Scriptname. when i try to run it through cron i'm receiving mail only but ... (7 Replies)
Discussion started by: naveen1.kumar
7 Replies

4. Shell Programming and Scripting

Mail Attachment...

Hi All, I am new to unix. I have written the script to identify the delimiter count for my source file and the output I have to capture in another file and that file should sent to mail with attachment. I have tried to send the attachment with below script . But I am not able to do that. Any... (2 Replies)
Discussion started by: suresh_target
2 Replies

5. Web Development

CGI param() function parameters

Hello again! Three posts in this forum now, as I am trying to understand how CGI is running and the interaction of the input and output with the server/browser. Very confused with them, especially with the param() function that I was trying to figure out how the parameters of it were passed in... (0 Replies)
Discussion started by: yifangt
0 Replies

6. Shell Programming and Scripting

mail function - script not working

#!/bin/bash { m() $mail='("$ ", Cc:"$me" -t, Subject:"$emailmyself" -s, $someinputfile")' } what I am trying to do is create a function have it load when type the letter "m" so all have to do type an address after it send email. it tell me syntax on line 4 but which... (2 Replies)
Discussion started by: ericde
2 Replies

7. Shell Programming and Scripting

Need help on bind param function in perl

Hi, I want to know what exactly bind paameter does? what exactly bind_param( 1, $siteName ) means? what 1 means? In some examples the bind_param is set like this: bind_param( 2, $siteName1 ) bind_param( 3, $siteName2 ) $sth = $dbh->prepare( " SELECT name,... (1 Reply)
Discussion started by: vanitham
1 Replies

8. UNIX for Dummies Questions & Answers

How to send html file in a mail not as an attachment but it should display in the mail in table for

Hi The below script working when we are sending the html as attachment can u please guide how to send thesmae data in table form direct in the mail and not in mail attachment . cat Employee.sql SET VERIFY OFF SET PAGESIZE 200 SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON - HEAD... (0 Replies)
Discussion started by: mani_isha
0 Replies

9. Shell Programming and Scripting

Mail attachment with unix mail

Hi Could someone help me with the details on how to send an attachment through mail in unix. I have an html file in my unix machine and I want this to be send to some mail id, plese help with the steps. Regards Ajay (2 Replies)
Discussion started by: ajaykumarboyana
2 Replies

10. UNIX for Advanced & Expert Users

mailx commannd - Mail and Attachment in same mail

Hi , I am using mailx command for sending the mails. Rightnow I am sending the attachment (by using uuencode $filename) as a seperate mail.I wanna send the attachment also with the same mail. (6 Replies)
Discussion started by: sharif
6 Replies

Featured Tech Videos