12-11-2008
File exists routine
Hello experts,
I need some help here..
I've written the following routine to check for existence of files. The routine does the following. It will look for a compressed ( .Z ) file and if it exists, then it will uncompress it, if it is already uncompressed, then it will just diplay a message saying "Already compressed" or else it will display the message saying "File doesn't exist". But I am sort of doing into infinite loop here.. Output below. Please can you help ? Your help is really appreciated.
uncompress () {
PARFILE=/gbwaaposoa2q4/ora01/app/oracle/orajobs/metadata
cat ${PARFILE} | while read line
do
TABNAME=`echo $line | awk '{print $1}'`
PART=`echo $line | awk '{print $2}'`
REF=`echo $line | awk '{print $3}'`
echo "Table name is ${TABNAME}"
echo "partition name is ${PART}"
echo "Business ref is ${REF}"
DMPFILE=${TABNAME}_PRT_${PART}.dmp
echo "exp dir is $EXPDIR "
cd ${EXPDIR}
if [ -f ${EXPDIR}/${DMPFILE}.Z ]; then
uncompress ${DMPFILE}.Z
elif [ -f ${EXPDIR}/${DMPFILE}]; then
echoLog "Dump file ${DMPFILE} exists on disk. Already uncompressed. "
else
echoLog "Dump file ${DMPFILE} does not exist. "
fi
done
}
My PARFILE is as below
QSFQ1> more metadata
SOACOE_LOGGER_SUMMARY 24112008 'CoPeRSender_v1.2.0:SalesEntity_ID=160598319'
SOACOE_AUDIT 24112008 'CoPeRSender_v1.2.0:SalesEntity_ID=160598319'
SOACOE_AUDIT 01122008 'S3DSenderESCP_v1.2.0:MsgId=1155460108'
SOACOE_AUDIT 24112008 'CoPeRSender_v1.2.0:Organization_CoPeR_ID=163823082'
SOACOE_AUDIT 24112008 'CoPeRSender_v1.2.0:SalesEntity_ID=165751555'
SOACOE_AUDIT 24112008 'CoPeRSender_v1.2.0:Organization_CoPeR_ID=200324'
SOACOE_AUDIT 24112008 'CoPeRSender_v1.2.0:Organization_CoPeR_ID=608834'
SOACOE_LOGGER_SUMMARY 24112008 'CoPeRSender_v1.2.0:Organization_CoPeR_ID=163823082'
SOACOE_LOGGER_SUMMARY 24112008 'CoPeRSender_v1.2.0:SalesEntity_ID=165751555'
SOACOE_LOGGER_SUMMARY 24112008 'CoPeRSender_v1.2.0:Organization_CoPeR_ID=200324'
SOACOE_LOGGER_SUMMARY 24112008 'CoPeRSender_v1.2.0:Organization_CoPeR_ID=608834'
I get the following output when i run this..
./restore_data.ksh[188]: [: missing ]
08:40:04 Dump file SOACOE_LOGGER_SUMMARY_PRT_24112008.dmp does not exist.
Table name is SOACOE_AUDIT
partition name is 24112008
Business ref is 'CoPeRSender_v1.2.0:SalesEntity_ID=160598319'
exp dir is /tmp
Table name is SOACOE_LOGGER_SUMMARY
partition name is 24112008
Business ref is 'CoPeRSender_v1.2.0:SalesEntity_ID=160598319'
exp dir is /tmp
./restore_data.ksh[188]: [: missing ]
08:40:04 Dump file SOACOE_LOGGER_SUMMARY_PRT_24112008.dmp does not exist.
Table name is SOACOE_AUDIT
partition name is 24112008
Business ref is 'CoPeRSender_v1.2.0:SalesEntity_ID=160598319'
exp dir is /tmp
Table name is SOACOE_LOGGER_SUMMARY
partition name is 24112008
Business ref is 'CoPeRSender_v1.2.0:SalesEntity_ID=160598319'
exp dir is /tmp
./restore_data.ksh[188]: [: missing ]
08:40:04 Dump file SOACOE_LOGGER_SUMMARY_PRT_24112008.dmp does not exist.
Table name is SOACOE_AUDIT
partition name is 24112008
Business ref is 'CoPeRSender_v1.2.0:SalesEntity_ID=160598319'
exp dir is /tmp
Table name is SOACOE_LOGGER_SUMMARY
partition name is 24112008
Business ref is 'CoPeRSender_v1.2.0:SalesEntity_ID=160598319'
exp dir is /tmp
./restore_data.ksh[188]: [: missing ]
08:40:04 Dump file SOACOE_LOGGER_SUMMARY_PRT_24112008.dmp does not exist.
Table name is SOACOE_AUDIT
partition name is 24112008
Business ref is 'CoPeRSender_v1.2.0:SalesEntity_ID=160598319'
exp dir is /tmp
Table name is SOACOE_LOGGER_SUMMARY
partition name is 24112008
Business ref is 'CoPeRSender_v1.2.0:SalesEntity_ID=160598319'
exp dir is /tmp
Thanks for your help in advance.
G
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
We have data files that are ftp'd every morning to a SUN server. The file names are exactly the same except for that each has the date included in its name. I have to write script to do 2 things:
STEP 1) Verify that the file arrived in morning.
STEP 2) Compare the file size of the current... (3 Replies)
Discussion started by: rbknisely
3 Replies
2. Shell Programming and Scripting
So I have a lot of Java applications on my servers all having their own folder from the applications subdirectory. Now, I need to do the following.
Search all the applications subdirectories for message.jar.
If the message.jar file exists, I need to search the application directory for... (1 Reply)
Discussion started by: mmdawg
1 Replies
3. Shell Programming and Scripting
Hi,
I have two files say xxx.txt and yyy.txt. xxx.txt is with list of patterns within double quotes. Eg.
"this is the line1"
"this is the line2"
The yyy.txt with lot of lines. eg:
"This is a test message which contains rubbish information just to fill the page which is of no use. this is... (3 Replies)
Discussion started by: abinash
3 Replies
4. Shell Programming and Scripting
Hi,
I have a CSV file in following manner:
server1,env1,patch1
server1,env1,patch2
server1,env1,patch3
server1,env2,patch1
server1,env2,patch3
server2,env3,patch1
server2,env3,patch5
server2,env4,patch1
server3,env6,patch1
server3,env7,patch2
server3,env7,patch3
I want to... (6 Replies)
Discussion started by: avikaljain
6 Replies
5. Shell Programming and Scripting
Hey all,
I'm brand new to script writing, I'm wanting to make a script that will ask for a file and then retrieve that file if it exists, and if it doesn't exist, create the file with the desired name, and I'm completely stuck.. so far..
#! bin/bash
echo "Enter desired file"
read "$file"
if ... (5 Replies)
Discussion started by: Byrang
5 Replies
6. Shell Programming and Scripting
Hi,
I am looking for a shell script with the following.
1. It should check whether a particular file exists in a location
#!/bin/sh
if ;
then
echo "xxx.txt File Exists"
else
echo "File Not Found"
fi
2. If file exists, it should check for the modified date and run a command... (2 Replies)
Discussion started by: karthikeyan_mac
2 Replies
7. Windows & DOS: Issues & Discussions
I'm looking to do pretty much what the title says.
I want a script that runs, it can run on Unix or Windows, doesn't matter, and searches a Samba shares for a .txt file.
If the file exists, the script will move (or possibly copy) the file from the Samba share into a directory on our Unix... (3 Replies)
Discussion started by: twcostello
3 Replies
8. Shell Programming and Scripting
Hi
#Testing for file existence
if ; then
echo 'SCHOOL data is available for processing'
else
echo 'SCHOOL DATA IS NOT AVAILABLE FOR PROCESSING'
:
i wrote a script, where it begins by checking if file exists or not.
If it exists, it truncates the database... (2 Replies)
Discussion started by: rxg
2 Replies
9. Shell Programming and Scripting
Hi experts,
I have two arrays one has the file paths to be searched in , and the other has the files to be serached.For eg
searchfile.dat will have
abc303
xyz123
i have to search for files that could be abc303*.dat or for that matter any extension . abc303*.dat.gz
The following code... (2 Replies)
Discussion started by: 100bees
2 Replies
10. UNIX for Beginners Questions & Answers
Dear All,
I am facing a small issue in my code where in I am searching for a file in a directory and if found it sends me a message along with the time and filename.
However if a file is not found based on the search pattern, the result which I am getting is all the files present in that... (7 Replies)
Discussion started by: grvk101
7 Replies