Sponsored Content
Top Forums Shell Programming and Scripting Echo print in different lines within email sent by Cron job Post 302469899 by cgkmal on Monday 8th of November 2010 03:02:52 PM
Old 11-08-2010
Echo print in different lines within email sent by Cron job

Hi all,

I think this could have a simple solution, just I canīt get it so far.
I have the script below that includes several echo commands in order
to show that every part of the script have been executed. A cron job
executes this script and when is completed the output is sent by email.


Code:
#!/usr/bin/sh

echo "+++++++++++++++++++++++++++++++++++++++++++++"
echo "+++++++++++++  PROCESS PART 1   +++++++++++++"
echo "+++++++++++++++++++++++++++++++++++++++++++++"

FILE1=$(ls)
for each in $FILE1
do echo "Processing $each...\n";
done

echo "+++++++++++++++++++++++++++++++++++++++++++++"
echo "+++++++++++++  PROCESS PART 2   +++++++++++++"
echo "+++++++++++++++++++++++++++++++++++++++++++++"

FILE2=$(ls *.txt)
for each in $FILE2
do echo "Processing $each...\n";
done

echo "+++++++++++++++++++++++++++++++++++++++++++++"
echo "+++++++++++++++   WORK DONE  ++++++++++++++++"
echo "+++++++++++++++++++++++++++++++++++++++++++++"

I only want to receive the output sent by the Cron job
correctly formatted(each echo print in different line)
as shown below:


Code:
+++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++  PROCESS PART 1   +++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++
Processing filename1.txt
Processing filename2.txt
Processing filename3.txt
+++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++  PROCESS PART 2   +++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++
Processing filename4.txt
.
.
.
Processing filenameN.txt
+++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++   WORK DONE  ++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++

I`ve tested adding \n at the end of every echo command but doesn`t seem to work.
The current output I get in the email received is continuos echo prints like this:


Code:
+++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++  PROCESS PART 1   +++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++
Processing filename1.txt...\n Processing filename2.txt...\n Processing filename3.txt...\n 
+++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++  PROCESS PART 2   +++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++
Processing filename4.txt...\n ....Processing filenameN.txt...\n 
+++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++   WORK DONE  ++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++

May somebody help me saying how can I get the echo prints in different line?

Thanks in advance for your help.
 

10 More Discussions You Might Find Interesting

1. AIX

Cron Job notification email

Hi, I'm fairly new to Aix and am looking for some help on the following. I have setup a cron job under root and want it to send the email once it's run to an external email address. I can get it to send the output in an email to me by using mail on the end of the crontab entry. But I would... (1 Reply)
Discussion started by: elmesy
1 Replies

2. Shell Programming and Scripting

Cron Job Automated Email Alternatives?

Hi guys, not sure if this would be the right place for this but I dont where else it would go... I'm new to Unix too, so please bare with me :) I guess first up some background on the situation. We have some scripts that run as cron jobs which monitor and check the health, etc of our servers.... (2 Replies)
Discussion started by: BrianD
2 Replies

3. Shell Programming and Scripting

how to avoid cron job output to send to the junk email folder?

Hi i created a cron job which invoke a shell script and output some content via email. Some times these output are sent to the junk email folder. i want these mails to be sent to inbox with some specific font. what i have to do? (4 Replies)
Discussion started by: vidhyaS
4 Replies

4. UNIX for Advanced & Expert Users

cron job to extact lines from files to another file and ftp to new server

i have a text file in this format: which creates a new one everyday in the form of filename _zing__r200_2012_8_10_log.txt Fri Aug 10 07:29:17 EDT 2012, usera(192.168.0.245) to anotheruser: hey top, this is a private test Fri Aug 10 07:29:28 EDT 2012, anotheruser(192.168.0.245) to usera: got... (2 Replies)
Discussion started by: bkkid
2 Replies

5. Solaris

Solaris cron job email generation not required

Hi, How do we stop default cron job emails bein generated in Solaris 10? All our cron entries are ending with /dev/null 2>&1 but still emails are being generated. And all these emails are nuisance, as they are also get relayed to our local network sendmail MTA server (for system email... (14 Replies)
Discussion started by: hasan.kamali
14 Replies

6. Shell Programming and Scripting

Commented cron job -- cron monitoring

Hi I have a requirement to write a shell script,that will check the all commented job in cron job.Please help !! (2 Replies)
Discussion started by: netdbaind
2 Replies

7. Shell Programming and Scripting

Cron job - Need to run Cron every quarter at particular time

Hi, 1) If some job supposed to run on 1st of every month at 7 AM In cron job when we have a blackout on the 1st ( i.e when 1st falls on a sunday ) how can we make the job run the next business day? 2) How can we run a job on 25th of every quarter 7 AM(jan,apr,jul,oct) And if 25th... (5 Replies)
Discussion started by: System Admin 77
5 Replies

8. Shell Programming and Scripting

Echo printing a line in 2 lines; expected to print in one line

Dear All, fileName: therm.txt nc3h7o2h 7/27/98 thermc 3h 8o 2 0g 300.000 5000.000 1390.000 41 1.47017550e+01 1.71731699e-02-5.91205329e-06 9.21842570e-10-5.36438880e-14 2 -2.99988556e+04-4.93387892e+01 2.34710908e+00 4.34517484e-02-2.65357553e-05 3 ... (7 Replies)
Discussion started by: linuxUser_
7 Replies

9. Shell Programming and Scripting

I want to send an email after cron job

I am using centos 6.4. I have a few cron jobs setup and they all work fine. However, I would like to enhance one of the crons. This is what I have at the moment: nice rsync -au /home/samba/wsaler/* /home/samba/wsaler.backup/wsaler.backup18pm date | /bin/mail -s "wsaler 3:00pm backup... (8 Replies)
Discussion started by: countrydj
8 Replies

10. Shell Programming and Scripting

Script that will send an email if the cron job did not run.

Team, Would like to know what is the best script that will send you an email if cronjob did not run. Thanks (4 Replies)
Discussion started by: kenshinhimura
4 Replies
echo(3XCURSES)						  X/Open Curses Library Functions					    echo(3XCURSES)

NAME
echo, noecho - enable/disable terminal echo SYNOPSIS
cc [ flag... ] file... -I /usr/xpg4/include -L /usr/xpg4/lib -R /usr/xpg4/lib -lcurses [ library... ] c89 [ flag... ] file... -lcurses [ library... ] #include <curses.h> int echo(void); int noecho(void); DESCRIPTION
The echo() function enables Echo mode for the current screen. The noecho() function disables Echo mode for the current screen. Initially, curses software echo mode is enabled and hardware echo mode of the tty driver is disabled. The echo() and noecho() functions control soft- ware echo only. Hardware echo must remain disabled for the duration of the application, else the behavior is undefined. RETURN VALUES
Upon successful completion, these functions return OK. Otherwise, they return ERR. ERRORS
No errors are defined. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
getch(3XCURSES), getstr(3XCURSES), initscr(3XCURSES), libcurses(3XCURSES), scanw(3XCURSES), attributes(5), standards(5) SunOS 5.10 5 Jun 2002 echo(3XCURSES)
All times are GMT -4. The time now is 02:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy