I am new to scripting.I am trying to mail the recent file contents but not the below script which i wrote is not working.Please guide me in finishing the script
Thanks,
Karthik
Last edited by Scrutinizer; 09-18-2016 at 02:28 AM..
Reason: code tags
To get the output of a command in a variable, you need to use backquotes instead of quotes.
but it is better to use this:
Also it is best to quote variable expansions:
In addition to what Scrutinizer has already said, the command:
is very strange. Unless the pathname matching pattern path/*.fnr fails to match any pathnames, the search of the file hierarchy rooted in /Directory doesn't do anything but slow down finding the last file in the file hierarchies rooted in the pathnames matched by path/*.fnr. Note also that unless the pathnames matched by path/*.fnr are non-directory files, the last pathname printed by find from this command will be random (i.e., not necessarily in alphanumeric order, not time created order; just random). What is the intent in picking a random file from the output of find?
And, once you have selected a file, copying the contents of file into a variable with the sole purpose of copying the text into a mail message wastes memory, time, CPU bandwidth, and I/O bandwidth. It would be MUCH more efficient to replace:
with:
If you can't find out yourself what the error msg means, and if you want meaningful help, wouldn't it be wise to answer questions needed to track down the details of your problem?
I am having trouble getting mail to work on a red hat server. At first I was getting this message.
Diagnostic-Code: X-Postfix; delivery temporarily suspended: connect to :25: Connection refused
Then added the port to my firewall. Then I temporarily turned off selinux. I then copied this file... (1 Reply)
Hi
I am looking for a help in designing a bash script on linux which can do below:-
1) Look in a specific directory for any new files
2) Mail the content of the new file
Appreciate any help
Regards
Neha (5 Replies)
Hi Guys
I want to write a script which search mail with subject line and after that I want the mail content in a file
please help guys.
Thanks
Atul Singh (3 Replies)
i have sun machines having solaris 9 & 10 OS . Now i need to send mail from the machines to my outlook account . I have the ip adress of OUTLOOK mail server. Now what are the setting i need to do in solaris machines so that i can use mailx or sendmail.
actually i am trying to automate the high... (2 Replies)
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)
Hi
I want to send out a file that generate 1st of each month that have formate like this 11012008_experience_rate_log.txt
Now I have setup a cronjob that usually sent this file in mail
like
cat /data02/transfer/*_experience_rate_log.txt | mail -s 'PICS EXP RATE Logs' lger@bd.com
So how... (3 Replies)
Hi,
I have been trying to shoot an email with the email body to be obtained from a file.
Can someone please help me with it..
I have been trying to use the MAILX commad for the same.
mailx -s "test email" -r sender@test.com < file.txt
but it sends the file as an attachment,while i... (3 Replies)
Hello,
I am new to perl and need to create a script that will read a file and pull a name from the file and send e-mail.
How can I use the following awk statement in a perl script?
grep UNIXadmins /root/mail.conf | awk '{ print $2}'
and use the output to send a e-mail.
Any help would... (1 Reply)
Hi,
Can anyone please tell me how to send a mail to a person in unix with a file attached. The file need to be zipped and then i want to send the mail to a person.
I know that we can able to send mail from unix using the command
mail mailaddress
to send a mail to a person with the... (5 Replies)