- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Checking response file in a script (ksh)
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2003 04:39 AM
03-04-2003 04:39 AM
Checking response file in a script (ksh)
I have a job that checks a file, creates a variable depending on the name of the file then renames the file once it has been sent. The problem I am having is checking the confirmation file that comes from the customer
so
DATE=$(date +%y%m%d)
CSVFILE=$(ls $DIR/$DATE[0-9][0-9].PAY | awk '{print $9}' | awk -F / '{print $6}' | cut -c1-8
The above gives me
03030401
01 = first file to have been sent today.
The problem I have is if I have to send more than one file in a day I will receive 2 response files, with a similar format as above
for eg
Yesterdays transfer failed. Today I am going to send
03030301.PAY
and Todays file
03030401.PAY
I should therefore receive from them.
03030401.CNF
and
03030402.CNF
Whats the best way to check that I have received the response files ? Bearing in mind the number of files that I have sent to them in a day and the file names I send will differ
I am no great script writer
Thanks in advance
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2003 05:00 AM
03-04-2003 05:00 AM
Re: Checking response file in a script (ksh)
You have a .CNF and a .PAY
ls -1 ./|grep PAY$| while read line
do
field=$(echo $line|cut -f1 -d".")
if [ -f $field".PAY" ] && [ -f $field".CNF" ]
then
echo $field".CNF" found
else
echo wrong
fi
done
ls -1 local directory and extract all .PAY
remove .PAY from name and in loop check
if .PAY and .CNF then ok else wrong.
Fill in what you want to do
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2003 05:16 AM
03-04-2003 05:16 AM
Re: Checking response file in a script (ksh)
cd
# Don't ls *.PAY in case it exceeds the number
# of arguments for a command. If this is not
# the case then use ls *.PAY and remove the
# if statement checking if it's a .PAY file
ls | {
while read FNAME
do
if [[ ${FNAME} != *(?).PAY ]];
then continue
fi
PREFIX=${FNAME%.PAY} # Remove the .PAY suffix
if [[ -f ${PREFIX}.CNF ]];
then continue
fi
# Here we have a .PAY without a corresponding
# .CNF file.
print "${FNAME} has no confirmation file!"
done
}
Regards,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2003 05:20 AM
03-04-2003 05:20 AM
Re: Checking response file in a script (ksh)
Assuming the sent and the received files reside in the same directory, something like this would work:
#!/usr/bin/sh
cd /tmp
for S in `ls [0-9][0-9]*.PAY`
do
R=${S%%.PAY}.CNF
ls ${R} >/dev/null 2>&1
if [ $? = 0 ]; then
echo "${R} received"
else
echo "${R} not received"
fi
done
exit 0
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2003 05:20 AM
03-04-2003 05:20 AM
Re: Checking response file in a script (ksh)
You are checking for every .PAY that there is a .CNF of the same name. I have just found that the .PAY is renamed to .PAZ which isn't a problem. The .CNF files are moved to another area and renamed, could be a problem.
For now though, there isn't necessarily a .PAZ with the same name ending .CNF
I could have
03030401.PAZ
and receieve
03030402.PAZ
How do I check that ?
Thanks in advance
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2003 05:23 AM
03-04-2003 05:23 AM
Re: Checking response file in a script (ksh)
Initially I was trying to define the receive files from the files that I had sent
CNFFILE=$( echo ${PAYPATH}/${CSVFILE} | /usr/bin/sed 's/\.PAY/\.CNF/g' | /usr/bin/awk -F / '{print $6}' )
But found I couldn't because they won't necessarily be the same
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2003 05:25 AM
03-04-2003 05:25 AM
Re: Checking response file in a script (ksh)
Similar method to Steve, checking the name of the .PAY matches the .CNF.
Thanks
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2003 05:28 AM
03-04-2003 05:28 AM
Re: Checking response file in a script (ksh)
I'm confusing you. lets stick with the .PAY and .CNF
I could have
03030401.PAY
and receieve
03030402.CNF
Thanks
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2003 05:41 AM
03-04-2003 05:41 AM
Re: Checking response file in a script (ksh)
Is there anything in the actual data that could be used to identify which is which? Also, you say that 'Yesterdays transfer failed. Today I am going to send ...', do you get something back to say that it failed?
Without some means of identification, the best you can hope to achieve is to flag up the fact that you haven't received confirmation for every file that you've sent.
Regards,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2003 05:57 AM
03-04-2003 05:57 AM
Re: Checking response file in a script (ksh)
{
SEND_NUM=$1
DATE=$(date +%y%m%d)
TDATE=$( TZ=CST-24 date +%y%m%d )
echo " SENDED FILE ${DATE}${SEND_NUM}" > ${DATE}${SEND_NUM}.PAY
touch ${TDATE}${SEND_NUM}.CNF
touch ${TDATE}${SEND_NUM}
}
check ( )
{
CHECKDATE=$1
for i in $CHECKDATE[0-9][1-9]
do
if [ -s $i.CNF ] ; then
echo $i.PAY Have been recived
else
echo $i.PAY Have been not recived yet
fi
done
}
send 01
send 02
check 030305
echo " CHANGIN SOME ONE "
echo " RECIVED 03030502.CNF" >03030502.CNF
check 030305
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2003 07:05 AM
03-04-2003 07:05 AM
Re: Checking response file in a script (ksh)
I have found that a script spawned from this one has a task that removes the .CNF file. Therefore there is only ever on in the directory at any one time
k ching
Simple check then
# Now Check for the Response file
#
CNFFILE=$(ls -ltr ${PAYPATH}/${DATE}[0-9][0-9].CNF | awk '{print $9}' | awk -F / '{print $6}')
if [[ -f ${PAYPATH}/${CNFFILE} ]]
then
transferSuccess="YES"
else
logError "Payment confirmation file not received "
fi
Thanks for the input everyone
Steve