Help with a shell script acting strange in AIX



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]

.



Relevant Pages

  • Re: question regarding image processing
    ... execute any extension. ... from original image file in file system, adds watermark, and outputs. ... the script only processes one by one. ... because if I have hundreds of thousands of images, database is ...
    (comp.lang.php)
  • Re: JS disabled offline?
    ... webpage he's viewing offline in IE6. ... in HTML document loaded in IE from the local file system is indeed disabled by default as a security measure, the browser will display a warning in a bar at the top of the content window. ... The context menu on that bar allows to have the page reloaded with script executed. ... If the system is not Windows XP SP 2 then someone has simply disabled script for IE for the local file system zone, IE has a zone model where features like scripting can be configured for each zone. ...
    (comp.lang.javascript)
  • Re: Add user in Unix from command Line
    ... what shell the script should be interpreted with. ... After having a couple of instances of kernel rebuild problems, ... Then I'd just restore the / file system. ... The extra 5 minutes to backup paid off in one or two instances, ...
    (comp.unix.sco.misc)
  • Re: Executing scripts on the remote machine
    ... the script itself and the shell interpreter. ... I rather think it sounds like the file system where the configure script ... flag, which may or may not have any relevance. ...
    (comp.security.ssh)
  • Re: /bin/csh script in GELI partition crashes 6.3-STABLE
    ... counting the swap partition). ... After initializing the GELI device file, ... directory trees from another file system, I tried running a C-shell script ... The script works fine in its ...
    (freebsd-questions)