Sponsored Content
Full Discussion: Help with search script
Top Forums UNIX for Advanced & Expert Users Help with search script Post 302134644 by kamitsin on Sunday 2nd of September 2007 02:50:33 AM
Old 09-02-2007
Quote:
check=`ls|grep cc3|wc -l` #This will not work always because if a file exists with cc3 it will count that file also, what you need is the files with extension cc3.

if [ $check -ne 0 ] # if file exists the value of $check will not be null
then
echo "INPUT FILE NOT FOUND FOR TODAY................................" > $LOG_DIR/errorperry.log # it should be file found
echo " " >> $LOG_DIR/errorperry.log
echo " " >> $LOG_DIR/errorperry.log
echo "Please verify the reason for the FAILURE....................." >>$LOG_DIR/errorperry.log
echo " " >> $LOG_DIR/errorperry.log
echo " " >> $LOG_DIR/errorperry.log
echo "EXITING FROM PROCESS..............................................................." >>$LOG_DIR/errorperry.log
cd $LOG_DIR
cat /disk1/stonehs1/log/perry/errorperry.log|mailx -s "ALERT-NO FILE FOUND" `cat maillist`
exit 1
else
echo "INPUT FILE FOUND FOR TODAY...................................." >> $LOG_DIR/perry.log
echo " " >> $LOG_DIR/perry.log
echo "NUMBER OF RECORDS IN INPUT FILE STarts.............................." >> $LOG_DIR/perry.log
echo " " >> $LOG_DIR/perry.log
echo " " >> $LOG_DIR/perry.log
wc -l *.cc3 >> $LOG_DIR/perry.log
echo " " >> $LOG_DIR/perry.log
echo " " >> $LOG_DIR/perry.log
echo " " >> $LOG_DIR/perry.log
cat /disk1/stonehs1/log/perry/perry.log|mailx -s "ALERT-FILE FOUND" `cat maillist`
exit 0
1) if unmatched - i am assuming that you have missed it while pasting the script.

2) problem with conditional statement logic.

if $check is not equal to zero then the file exists else does not exist.
You have put it otherway round so even if the file exist you will get the message file does not exist.

make it

Code:
if [[ $check -eq 0 ]]

or reverse the statements if the condition is true.

3) you would have been able to check the error yourself with the value of $check because you always had the debugging on in the script.

Cheers,
K
kamitsin
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

script to search all the directories

Hi there, Is there any command or script to search all the directories for duplicated files? Thanks, Abrahim (3 Replies)
Discussion started by: abk
3 Replies

2. Shell Programming and Scripting

Search script

I need to create a script called 'find_data' that will search a file by passing two parameters to it :confused: . I'm pretty good with scripting but haven't really gotten into sed and awk that much (and no perl whatsoever). I'm really at a loss and need to get something working in the next... (14 Replies)
Discussion started by: BCarlson
14 Replies

3. Shell Programming and Scripting

Search File Script

Nice forum for noobs like me to UNIX. With that said, I need assistance. I am trying to make a script to search files for a specific date and string within the file. Then I need the script to move the file that have the specific date and string to a directory. In the interim I have been manually... (7 Replies)
Discussion started by: I4ce
7 Replies

4. Shell Programming and Scripting

script to search a file

hi all i have a requirement to write a script which will serach a file in a particuar location for 3 hours from the time when the script is run.if during this period the file arrives in a particular location then this will transmit the file to a other server.please help me writing the script which... (1 Reply)
Discussion started by: dr46014
1 Replies

5. Shell Programming and Scripting

Small Search script

I need to write a small shell script which does the following : I have a file : root/var/log/ocmp/ocmpclient.log This is a log file which is continuosly getting updated . I have to keep looking into this file all the time. I have to look for four keywords, "File Detected", File Sending",... (2 Replies)
Discussion started by: appu1987
2 Replies

6. Shell Programming and Scripting

Log Search Script

Hi, I am trying to write a script to search a log- IPaddress being the search criteria, I would ideally like the script to ask the ipaddress Enter IP address - 244.258.27.225 And the ideal result would be for the script to get all the entries in the log file for a particular IP address,... (3 Replies)
Discussion started by: fuzion.hyd
3 Replies

7. Shell Programming and Scripting

Search and Copy Script

Dear All, I would like to create a Unix script which basically searches for files which are more than 2 days old and copy only the new files to the destination. What i mean is if the destination may have most of the files, it may not have only last 2 to 3 days file. I am able to create the... (6 Replies)
Discussion started by: rrb2009
6 Replies

8. Shell Programming and Scripting

Please help in creating search script

Hi all, Hope everyone is doing fine. I need a help in creating search script. I have file which contains job names and job recs. I need to select specific job name and next line which is job rec job (BLREEXTT) { Record B${cycle}${month}${year}000075; follows BLCYRRTCHKT; ... (5 Replies)
Discussion started by: taksistalo
5 Replies

9. UNIX for Dummies Questions & Answers

Help with ip search script

Hi Obviously first time poster here. I have been set the task of creating a network diagram for each of our clients in the business i work for. After identifying ip adresses of firewalls name servers and the like im got to the point where i found it impracticle to go through 254 ip address and... (6 Replies)
Discussion started by: jeked
6 Replies

10. Shell Programming and Scripting

Timebased search script

Hi there first of all, sry for my bad english and possible mistakes .-) I write scripts for my server to get my live easier. So my next one will be a script, where I can find special files in a folder. I put with a script of mine files in a folder on the server with following name... (5 Replies)
Discussion started by: bigsanch
5 Replies
RMF(1)                                                               [nmh-1.5]                                                              RMF(1)

NAME
rmf - remove an nmh folder SYNOPSIS
rmf [+folder] [-interactive | -nointeractive] [-version] [-help] DESCRIPTION
Rmf removes all of the messages (files) within the specified (or default) folder, and then removes the folder (directory) itself. If there are any files within the folder which are not a part of nmh, they will not be removed, and an error will be produced. If the folder is given explicitly or the -nointeractive option is given, then the folder will be removed without confirmation. Otherwise, the user will be asked for confirmation. If rmf can't find the current folder, for some reason, the folder to be removed defaults to `+inbox' (unless overridden by user's profile entry "Inbox") with confirmation. If the folder being removed is a subfolder, the parent folder will become the new current folder, and rmf will produce a message telling the user this has happened. This provides an easy mechanism for selecting a set of messages, operating on the list, then removing the list and returning to the current folder from which the list was extracted. If rmf s used on a read-only folder, it will delete all the (private) sequences (i.e., "atr-seq-folder" entries) for this folder from your context without affecting the folder itself. Rmf irreversibly deletes messages that don't have other links, so use it with caution. FILES
$HOME/.mh_profile The user profile PROFILE COMPONENTS
Path: To determine the user's nmh directory Current-Folder: To find the default current folder Inbox: To find the default inbox SEE ALSO
rmm(1) DEFAULTS
`+folder' defaults to the current folder, usually with confirmation `-interactive' if +folder' not given, `-nointeractive' otherwise CONTEXT
Rmf will set the current folder to the parent folder if a subfolder is removed; or if the current folder is removed, it will make "inbox" current. Otherwise, it doesn't change the current folder or message. BUGS
Although intuitively one would suspect that rmf works recursively, it does not. Hence if you have a sub-folder within a folder, in order to rmf the parent, you must first rmf each of the children. MH.6.8 11 June 2012 RMF(1)
All times are GMT -4. The time now is 09:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy