Very Urgent... Problem in generating the mail from crontab


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Very Urgent... Problem in generating the mail from crontab
# 1  
Old 08-01-2008
Very Urgent... Problem in generating the mail from crontab

Hi,

I wrote a script which generates a mail automatically under certain condition. When i execute the script manually in unix the script is getting executed and the condition works accordingly and the mail is also generated. But when it is pu into cron the mail is not generated and the condition also seems to be going wrong. The return code of the mail command is '1'. Please help me out.

Below is my sample format of my script,

#!/bin/sh
echo "The Job Successfully scheduled at : `date` "
cd **to some path**
ls **some condition** > filetmp.dat
while read line
do
grep $line file.dat > a1.dat
res=`echo $?`
echo "$res"
if [ $res = "1" ]
then
len=`echo $line | wc -c`
echo $len
if [ $len = "30" ]
then
subfile=`echo $line | cut -c1-18`
echo $subfile
cd **to some path**
grep TFS $subfile > a2.dat
tfs=`echo $?`
if [ $tfs = "0" ]
then
echo "FOUND"
else
echo "NOT FOUND"
while read address
do
echo "
Hi ,
This is an alert " | Mail -s "Test Mail" $address
echo "$? --> Mail Status for $address"
done < "addr.dat"
fi
elif [ $len = "44" ]
then
subfile=`echo $line | cut -c1-18`
echo $subfile
cd **to some path**
grep TFS $subfile > a2.dat
tfs=`echo $?`
if [ $tfs = "0" ]
then
echo "FOUND"
else
echo "NOT FOUND"
while read address
do
echo "
Hi ,
This is an alert " | Mail -s "Test Mail: " $address
echo "$? --> Mail Status for $address"
done < "addr.dat"
fi
else
subfile1=`echo $line | cut -c1-35`
echo $subfile1
cd **to some path**
grep TFS $subfile1 > a2.dat
tfs=`echo $?`
if [ $tfs = "0" ]
then
echo "FOUND"
else
echo "NOT FOUND"
while read address
do
echo "
Hi ,
This is an alert" | Mail -s "Test Mail:" $address
echo "$? --> Mail Status for $address"
done < "addr.dat"
fi
fi
fi
done < "filetemp.dat"
mv filetmp.dat file.dat
echo "The Job Successfully ended at : `date` "



Mail is not generated when scheduled into cron and the grep condition is not working when scheduled into cron. Please help me...
Image
# 2  
Old 08-01-2008
No duplicate posting, please,
continue here.

Thanks!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Crontab not generating file in mapped drive in windows

Dear Experts, I've schedule scripts with the help of Cronjob, and output should be generated on windows mapped drive, Earlier 2 days its was working fine and now my cronjob is not generating file on windows network drive. Please suggest. Linux details given below. $ tail... (9 Replies)
Discussion started by: Mohammed Fareed
9 Replies

2. Shell Programming and Scripting

Problem with script generating files in directory recursively

I have a script which generates recursively some files in folders for a given root folder. I have checks for permissions and it works for all folders except one(i have 777 permission on it). When i try calling the script in problematic folder(problematic folder being root folder), script works as... (2 Replies)
Discussion started by: bb2
2 Replies

3. Solaris

send mail from crontab

I want the crontab to send me the output along with subject to my email address. In order to do that, I tried the following : 02 15 15 06 * /ora01/script.sh | /bin/mail -s "Task Complete" xxxxxxxxxxxx.xxxxxxxxxxxxxx@xxxxxxxxxxxxxx.com & I am getting the output in the email but there is no... (2 Replies)
Discussion started by: lg123
2 Replies

4. Fedora

Problem while generating ssh keys.

Hi all, I am facing an issue while creating the ssh keys. i am using fedora 9 Please let me know how to solve this issue # ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no... (5 Replies)
Discussion started by: kalyankalyan
5 Replies

5. Solaris

problem when generating dsa key

i got this while trying generating a dsa key on solaris 10 x86 platform how can i solve it? (0 Replies)
Discussion started by: conandor
0 Replies

6. UNIX for Dummies Questions & Answers

Urgent -Please help me 'mail' option not working

Hi , I have already posted a post regarding this, but i didn't get my problem solve, so some body help me as it was urgent for me, my mail option is not working, when i send a mail, it is strucking in /var/spool/mqueue folder. and i am getting struck there itself, i see below two files are... (1 Reply)
Discussion started by: mars_girish9
1 Replies

7. UNIX for Dummies Questions & Answers

Problems in generating the mail from cron -- very urgent help me

Hi, I wrote a script which generates a mail automatically under certain condition. When i execute the script manually in unix the script is getting executed and the condition works accordingly and the mail is also generated. But when it is pu into cron the mail is not generated and the... (4 Replies)
Discussion started by: thiru_cs
4 Replies

8. Solaris

Problem in generating codes in solaris server!!

I have a solaris server having oracle and oracle apps running ! When some one attempts to generate a code, they click a link on the web interface which runs an rsh script from a computer called Helpdesk onto my solaris server and what happens is the web interface show an error message saying... (4 Replies)
Discussion started by: SmartestVEGA
4 Replies

9. Shell Programming and Scripting

Generating a report -Formatted printing -Urgent

Hi, My aim is to generate a report using shell script. There are various formats fields coloumns etc. I want to print in a single line (row) but in different coloumn as given below: field1 field2 field3 field4 ....... ....... ...... ....... The spacing... (1 Reply)
Discussion started by: jisha
1 Replies

10. UNIX for Dummies Questions & Answers

Crontab - URGENT pls

I put 30 2 * * * /usr/bin/tar cvf /dev/rct0 /u/csa/* in my crontab file (SCO5) but I want to be absolutely sure that the backup job finishes successfully. I know that whenever cron cannot execute a command sends an e-mail to root with the error code and/or an explanation of the problem. ... (6 Replies)
Discussion started by: pappous
6 Replies
Login or Register to Ask a Question