Help with a shell script acting strange in AIX
- From: srichards@xxxxxxxxxxxxxxxx
- Date: 19 Dec 2005 10:06:24 -0800
I have this Korn shell script that runs via a cron entry. This is
running on AIX 5.2L . It runs in a loop "watching" a specific file
system for files with a certain name. The file system that it is
watching is an upload file system for an FTP server. When files that
are the correct name come in, it takes the extension of the file and
runs several other scripts against the file with the extension as a
vairable. The script looks like:
[CODE]
#!/bin/ksh
#
# Function : is_file_arrived file
# Arg(s) : file = file to verify
# Output : None
# Status : 0 = yes file arrived, 1 = no
# Env. : IFA_WAIT : interval (secs) for file size check (def=5)
#
is_file_arrived() {
[ -z "$1" ] && return 1
local file=$1
local arrived=1
local size1 size2
if [ -f "$file" -a -z "$(fuser $file 2> /dev/null)" ] ; then
size1=$(ls -l $file 2>/dev/null | awk '{print $5}')
sleep ${IFA_WAIT:-15}
size2=$(ls -l $file 2>/dev/null | awk '{print $5}')
[ ${size1:-1} -eq ${size2:-2} ] && arrived=0
fi
return $arrived
}
processFile ()
{
local fileName=$1
local fileExtension=$2
local fileNewName="/ftp/datafiles/str${fileExtension}.asc"
local filePrintPath="/ftp/print"
local fileTmpPath="/ftp/tmp"
local fileODIName="str${fileExtension}.pos"
mv -Eignore $fileName $fileNewName # Add status check
prepup $fileNewName $fileExtension
mv -Eignore $filePrintPath/$fileODIName $fileTmpPath/$fileODIName
save2tmp $fileExtension
call_siu $fileExtension
}
# Main Processing
nsec=1
#hile :
while [[ "$(date +%H%M)" -lt 2329 ]]
do
for fileName in /ftp/datafiles/UPLOAD.[0-9][0-9][0-9][0-9]
do
fileExtension=${fileName#*.}
is_file_arrived "$fileName" && nsec=1 && processFile $fileName
$fileExtens
ion
done
sleep $nsec
case $nsec in
1) nsec=15;;
15) nsec=45;;
45) nsec=90;;
90) nsec=300;;
300) nsec=600;;
600) nsec=900;;
*) nsec=1800;;
esac
done
[/CODE]
.... the problem is that I keep getting files that are "stuck" in the
/ftp/datafiles file system. The log from the crontab states that these
files have the incorrect permission for the script to process them? The
wierd thing is that it happens after the script initially renames them
to "str####.asc" so the cron user (which has permissions to the
filesystem and the files intially) was able to rename them? The log
looks like:
[CODE]
+ is_file_arrived /gers/genret/datafiles/UPLOAD.0043
+ nsec=1
+ processFile /gers/genret/datafiles/UPLOAD.0043 0043
mv: 0653-401 Cannot rename /gers/genret/print/str0043.pos to
/gers/genret/tmp/str0043.pos:
A file or directory in the path name does not exist.
mv: /gers/genret/datafiles/str0043.asc: The file access permissions do
not allow
the specified action.
[/CODE]
.
- Follow-Ups:
- Re: Help with a shell script acting strange in AIX
- From: Laurenz Albe
- Re: Help with a shell script acting strange in AIX
- Prev by Date: Re: ATAPE Driver Upgrades
- Next by Date: Re: ATAPE Driver Upgrades
- Previous by thread: ATAPE Driver Upgrades
- Next by thread: Re: Help with a shell script acting strange in AIX
- Index(es):
Relevant Pages
|
|