Sponsored Content
Full Discussion: file checking
Top Forums Shell Programming and Scripting file checking Post 302253859 by mohan705 on Sunday 2nd of November 2008 11:37:25 PM
Old 11-03-2008
file checking

Hi
I need to check the file,if file exist ,do some other opearations and make it successful.
If file does not exist skip all steaps,go to last step and make it succesful.below is scripts is working for file exist but its not working for file not exist

Code:
                                                                        
. $HOME/.profile								
                                                                           
if [ -r $Folder/log/restart_xxxE.txt ]          				
then									
		chmod 774 $Folder/log/restart_xxxE.txt                         
	. $Folder/log/restart_xxxE.txt				
else								restart_step_xxxE=0 							
fi				   					
if [ $restart_step_xxxE = 0 ] || [ $restart_step_xxxE = 20 ]			
then								
     if [ $restart_step_xxxE = 20 ]					
	  then							
		echo "Restarting Job from step 20..."				
     fi				   				
echo "restart_step_xxxE=20" > $Folder/log/restart_xxxE.txt			
   echo "export restart_step_xxxE" >> $Folder/log/restart_xxxE.txt
	
if [ ! -f $BDWStageFolder/userdata_hk/BM.DWPRD.HK.BSLASTCLS_APR.DAT]
 then 
 echo  "Job Executed Successfully"
fi
				
$Folder/jobs/readtrailer_count $BDWStageFolder/userdata_hk/BM.DWPRD.HK.BSLASTCLS_APR.DAT $BDWStageFolder/userdata_hk/BM.DWPRD.HK.BSLASTCLS_APR.TRAILER.DAT       						
	stat=$?                             					
                                       					
		if [ $stat -gt 0 ]						
	then								
		echo "restart_step_xxxE=20" > $Folder/log/restart_xxxE.txt		
   		echo "export restart_step_xxxE" >> $Folder/log/restart_xxxE.txt	
   		echo "STEP FAILED.PLEASE CHECK..." 		        
 			rm -f $Folder/log/JOB_xxx_EXTRACT.txt					
   		exit 1							
 		fi								
										
										
 rm -f $Folder/log/restart_xxxE.txt					
                             						
 rm -f $Folder/log/JOB_xxx_EXTRACT.txt						
                             						
 else                             						
  echo "Skipping step 20 ..."   
                          			
 fi     

step 30 --For check file counts ...
............




  TR: "Job Executed Successfully"                                                           
#*                                                                   *    
#*********************************************************************    
#*                                                                        
#*       STEP: 190    Message                                              
#*                                                                   *    
#*********************************************************************    
#*                                                                        
                                                                           
. $HOME/.profile								
                                                                           
if [ -r Folder/log/restart_xxxT.txt ]          				
then									
		chmod 774 Folder/log/restart_xxxT.txt                         
	. Folder/log/restart_xxxT.txt					
else									
	restart_step_xxxT=0 							
fi				   						
if [ $restart_step_xxxT = 0 ] || [ $restart_step_xxxT = 190 ]			
then									
     if [ $restart_step_xxxT = 190 ]						
	  then									
		echo "Restarting Job from step 190..."				
     fi				   					
echo "restart_step_xxxT=190" > Folder/log/restart_xxxT.txt			
   echo "export restart_step_xxxT" >> Folder/log/restart_xxxT.txt	
										
										
   		echo  "Job Executed Successfully"


Thanks and Regards,
MR
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Error checking a file from previous file size

Hi, I'm currently trying to write a script that checks a log file for certain errors. Once checked it then records the filesize in another file. All this is fine, my problem is that the next time I do my error check I only want to check from previously recorded filesize to the end of file. I'm... (2 Replies)
Discussion started by: stuck1
2 Replies

2. Shell Programming and Scripting

Multiple file existence and checking file size

I want to check the files in particular directory are more that 0 Bytes i.e, Non zero byte file. The script should print a msg if all the files in that directory are empty( 0 Byte). (2 Replies)
Discussion started by: lathish
2 Replies

3. Shell Programming and Scripting

Checking for a control file before processing a data file

Hi All, I am very new to Shell scripting... I got a requirement. I will have few text files(data files) in a particular directory. they will be with .txt extension. With same name, but with a different extension control files also will be there. For example, Sample_20081001.txt is the data... (4 Replies)
Discussion started by: purna.cherukuri
4 Replies

4. Shell Programming and Scripting

Script check for file, alert if not there, and continue checking until file arrives

All, Is there a way to keep checking for a file over and over again in the same script for an interval of time? Ie If { mail -user continue checking until file arrives file arrives tasks exit I don't want the script to run each time and email the user each time a file... (4 Replies)
Discussion started by: markdjones82
4 Replies

5. UNIX for Dummies Questions & Answers

Checking for same file

I was wondering if there is a way to to check if two files are the same. I've tried writing a script called samefile, which takes in two arguments (files) and attempts to compare them to see if they're the same file. Here is what I have so far: if then echo "The two files are not the... (0 Replies)
Discussion started by: Trinimini
0 Replies

6. UNIX for Dummies Questions & Answers

Checking for same file name

I was wondering if there is a way to to check if two files are the same. I've tried writing a script called samefile, which takes in two arguments (files) and attempts to compare them to see if they're the same file. Here is what I have so far: if then echo "The two files are not the... (4 Replies)
Discussion started by: Trinimini
4 Replies

7. UNIX for Advanced & Expert Users

File checking

Hello Experts, File contains 5 columns with | delimeter. 1,3,5 columns are required columns means it should contains values. reset of the columns it will contain value or not. test1.txt: Code: a@a.com|a|b|c|d |a|b|c|d output: test2.txt Code: a@a.com|a|b|c|d I need the unix... (1 Reply)
Discussion started by: muralikri
1 Replies

8. Shell Programming and Scripting

File checking

Hello Experts, File contains 5 columns with | delimeter. 1,3,5 columns are required columns means it should contains values. reset of the columns it will contain value or not. test1.txt: a@a.com|a|b|c|d |a|b|c|d output: test2.txt a@a.com|a|b|c|d I need the unix script, read the... (5 Replies)
Discussion started by: muralikri
5 Replies

9. Shell Programming and Scripting

Awk: File Checking Issues with 9 multiple file

Hi, I have 9 files which are generated dynamically & if there is a some condition which doesn't meet the criteria then file is not created or is of zero size. so further i am unable to consolidate the files based on following code 1 awk -F, -v ptime="201407" 'FNR==1... (3 Replies)
Discussion started by: siramitsharma
3 Replies

10. Shell Programming and Scripting

Checking Multiple File existance in a UNIX folder(Note: File names are all different)

HI Guys, I have some 8 files with different name and extensions. I need to check if they are present in a specific folder or not and also want that script to show me which all are not present. I can write if condition for each file but from a developer perspective , i feel that is not a good... (3 Replies)
Discussion started by: shankarpanda003
3 Replies
Email::Folder::Mbox(3pm)				User Contributed Perl Documentation				  Email::Folder::Mbox(3pm)

NAME
Email::Folder::Mbox - reads raw RFC822 mails from an mbox file SYNOPSIS
This isa Email::Folder::Reader - read about its API there. DESCRIPTION
Does exactly what it says on the tin - fetches raw RFC822 mails from an mbox. The mbox format is described at http://www.qmail.org/man/man5/mbox.html We attempt to read an mbox as through it's the mboxcl2 variant, falling back to regular mbox mode if there is no "Content-Length" header to be found. OPTIONS The new constructor takes extra options. "eol" This indicates what the line-ending style is to be. The default is " ", but for handling files with mac line-endings you would want to specify "eol => "x0d"" "jwz_From_" The value is taken as a boolean that governs what is used match as a message seperator. If false we use the mutt style /^From S+s+(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)/ /^From (?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)/; If true we use /^From / In deference to this extract from <http://www.jwz.org/doc/content-length.html> Essentially the only safe way to parse that file format is to consider all lines which begin with the characters ``From '' (From-space), which are preceded by a blank line or beginning-of-file, to be the division between messages. That is, the delimiter is " From .* " except for the very first message in the file, where it is "^From .* ". Some people will tell you that you should do stricter parsing on those lines: check for user names and dates and so on. They are wrong. The random crap that has traditionally been dumped into that line is without bound; comparing the first five characters is the only safe and portable thing to do. Usually, but not always, the next token on the line after ``From '' will be a user-id, or email address, or UUCP path, and usually the next thing on the line will be a date specification, in some format, and usually there's nothing after that. But you can't rely on any of this. Defaults to false. "seek_to" Seek to an offset when opening the mbox. When used in combination with ->tell you may be able to resume reading, with a trailing wind. "tell" This returns the current filehandle position in the mbox. AUTHORS
Simon Wistow <simon@thegestalt.org> Richard Clamp <richardc@unixbeard.net> COPYING
Copyright 2003, Simon Wistow Distributed under the same terms as Perl itself. This software is under no warranty and will probably ruin your life, kill your friends, burn your house and bring about the apocolapyse. SEE ALSO
Email::LocalDelivery, Email::Folder perl v5.10.0 2009-07-27 Email::Folder::Mbox(3pm)
All times are GMT -4. The time now is 04:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy