The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #26 (permalink)  
Old 07-24-2006
dsravan dsravan is offline
Registered User
 

Join Date: Jul 2006
Posts: 183
Hi,

I have a problem with the script below. Basically it checks whether there is any file present with the name CARE01_DLY present for today's date in the directory /biddf/ab6498/dev/ctl and if the count =1 it says success otherwise error. But it doesn't seem to take the todays date file but checking if the file is present and saying success if the file is present with out checking for todays date. But i want the script to check for todays file only and if found it should through success otherwise error. The name of the file is sent as an argument to the script.

Quote:
#!/bin/ksh
dir=/biddf/ab6498/dev/ctl
export dir
set -x
myfilepattern=$@
integer filecount=0
for file in $myfilepattern_???_$(date +%Y%m%d) ; do
filecount=$filecount+1
done

if (( $filecount == 10 )); then
print "success"
exit 0
else
print "failure"
exit 1
fi
here is the output: The script is called like this script3.ksh BARE02_DLY

Quote:
+ dir=/biddf/ab6498/dev/ctl
+ export dir
+ set -x
+ myfilepattern=BARE02_DLY
+ typeset -i filecount=0
+ date +%Y%m%d
+ filecount=0+1
+ let 1 == 1
+ print success
success
+ exit 0
There is no file with this name for today but it's saying success.

Please help.
Reply With Quote