Check This Script very Urgent PLZZZZZ


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Check This Script very Urgent PLZZZZZ
# 1  
Old 05-16-2011
MySQL Check This Script very Urgent PLZZZZZ

Hi guys,

I am sending the script i created..plzzz check it correct if any mistakes...Smilie.

Plz reply early by today..

here i want to find the files based on date , if files are avaliable i want to send a mail to the user. here there are a total of 43 files. they are constant.

Here is the script..
Code:
#!/bin/sh
Date=$(date +"%y%m%d")
find /stage_area/loadfiles/telsims/test/ -type f -name "*$Date" -print > /tmp/testfile.txt

returncode=$? # check here is it right to use like this
if [ $returncode != 0 ]; then

echo " Files are not avaliable"
exit $?

else 

# Echo $?
temp=`cat /tmp/testfile.txt`
i = 0

for x in $temp
# echo $?
# Reads the test file and counts the number of lines ie associated to i. 
do
i =` expr $i + 1 ` # for each line i increments
#echo $?
done
if [ $i == 43 ]
then # checking the condition that all file are avaliable or not
echo "Files Avalaible You can Start Your Process Now" | mailx -s "File Found" xyz@domain.com
# If condition trues sends an email to the user.
rm -rf /tmp/testfile.txt # removing the test file.
break
fi
fi

SmilieSmilieSmilieSmilieSmilie

Last edited by Franklin52; 05-16-2011 at 03:00 AM.. Reason: Please use code tags and indentation
# 2  
Old 05-16-2011
Code:
exit $?

will always return zero because the previous command executed is echo.

Code:
for x in $temp

can be changed to for efficiency
Code:
cat /tmp/testfile.txt|while read x

Rest looks ok. I hope you have tested it already
This User Gave Thanks to kumaran_5555 For This Post:
# 3  
Old 05-16-2011
Hi kumaran,

thanks for your advice..

i want to exit based on the return code..

can i use directky exit or exit $returncode
# 4  
Old 05-16-2011
Everyone at the UNIX and Linux Forums gives their best effort to reply to all questions in a timely manner. For this reason, posting questions with subjects like "Urgent!" or "Emergency" and demanding a fast reply are not permitted in the regular forums.

For members who want a higher visibility to their questions, we suggest you post in the Emergency UNIX and Linux Support Forum. This forum is given a higher priority than our regular forums.

Posting a new question in the Emergency UNIX and Linux Support Forum requires forum Bits. We monitor this forum to help people with emergencies, but we do not not guarantee response time or best answers. However, we will treat your post with a higher priority and give our best efforts to help you.

If you have posted a question in the regular forum with a subject "Urgent" "Emergency" or similar idea, we will, more-than-likely, close your thread and post this reply, redirecting you to the proper forum.

Of course, you can always post a descriptive subject text, remove words like "Urgent" etc. (from your subject and post) and post in the regular forums at any time.


Thank you.

The UNIX and Linux Forums
This User Gave Thanks to Scott For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

URGENT Reading a file and assessing the syntax shell script URGENT

I am trying to write a shell script which takes an input file as an arguement in the terminal e.g. bash shellscriptname.sh input.txt. I would like for the file to be read line by line each time checking if the .txt file contains certain words or letters(validating the syntax). If the line being... (1 Reply)
Discussion started by: Gurdza32
1 Replies

2. Shell Programming and Scripting

Urgent: File Check in remote server

Hi Experts, I need a script in which I need to scp a file /home/chandan/abc.txt to a remote server using scp. Then I need to check whether scp is successful or not. How am I going to write this code? My Server Name: myserver File Name On My Server: /home/chandan/abc.txt Destination Server... (1 Reply)
Discussion started by: ChandanN
1 Replies

3. Shell Programming and Scripting

script to check if another script is running and if so, then sleep for sometime and check again

Hi, I am a unix newbie. I need to write a script to check wheteher another script is still running. If it is, then sleep for 30m and then check again if the script is running. If the script has stopped running then, I need to come out of the loop. I am using RHEL 5.2 (2 Replies)
Discussion started by: mathews
2 Replies

4. Shell Programming and Scripting

urgent help : want to check data in oracle from flate file

Hi All, I have a flat file like this on unix AIX server: MXBOFO CSWP 5340 3794499 MXBOBIS CSWP 5340 3581124 MXBOFO CSWP 5340 3794531 MXBOBIS CSWP 5340 3583720 MXBOFO CSWP 5340 3794514 MXBOBIS CSWP 5340 3580763 MXBOFO CSWP 5340 3795578 MXBOBIS CSWP 5340 3794995 MXBOFO CSWP 5340 3710835... (3 Replies)
Discussion started by: unknown123
3 Replies

5. Shell Programming and Scripting

(Urgent):Creating flat file using sql script and sqlplus from UNIX Shell Script

Hi, I need help urgently for following issue. Pls help me to resolve this issue. I am calling sql script file(file1.sql) from UNIX Shell Script(script1.ksh) using sql plus and trying to create flat file that contains all records returned from SQL query in SQL script(file1.sql) I given... (6 Replies)
Discussion started by: praka
6 Replies

6. Shell Programming and Scripting

I want an urgent script

Hi I want a script which reads a file and ftped the content of that file into another server.The file saved in new location as filename.date (3 Replies)
Discussion started by: Renjesh
3 Replies

7. Shell Programming and Scripting

Urgent:FileSystem Check Script

This script monitors a FileSystem named /Monthly and send a page; works great but I need to monitor /Daily/All ....Im getting Syntax Error MSG=`df -Ik|awk '$6~/Monthly$/{gsub("%"," "); if ($5>20){print "FS:Monthly filesystem is "$5"%"}}'` if then echo $MSG | mail 2149724690@mobilecomm.net... (1 Reply)
Discussion started by: Openware
1 Replies

8. Forum Support Area for Unregistered Users & Account Problems

Help plzzzzz!!!!!!!!!

Plz show where to post a new thread in a technical forum!!!! (1 Reply)
Discussion started by: kleendine
1 Replies

9. Shell Programming and Scripting

check position of end of line(URGENT PLS)

I Have to check in a file that all the lines are ending at same posiotin. Ex : line 1 is ending at position 88 line 2 should at same position i.e 88 Thanks in advance (6 Replies)
Discussion started by: evvander
6 Replies

10. UNIX for Dummies Questions & Answers

Script to check for a file, check for 2hrs. then quit

I wish to seach a Dir for a specific file, once the file is found i will perform additional logic. If the file is not found within two hours, i would like to exit. Logically, I'm looking for the best way to approach this Thanks for any assistance in advance. Note: I'm using a C shell and... (2 Replies)
Discussion started by: mmarsh
2 Replies
Login or Register to Ask a Question