![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Performing Script on Multiple Files | zanetti321 | UNIX for Advanced & Expert Users | 3 | 04-16-2008 07:42 AM |
| Script to delete all data from multiple files | uni_ajay_r | Shell Programming and Scripting | 5 | 03-29-2006 08:05 AM |
| Need a script to delete multiple files | navycow | UNIX for Dummies Questions & Answers | 3 | 01-16-2006 11:50 AM |
| Combining Multiple files in one in a perl script | rahulrathod | Shell Programming and Scripting | 1 | 12-17-2005 10:51 PM |
| Perform a command to multiple files | mcgrawa | UNIX for Dummies Questions & Answers | 4 | 09-25-2003 01:40 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have this Korn script that I wrote (with some help) that is run by cron. I basically watches a file system for a specific filename to be uploaded (via FTP), checks to make sure that the file is no longer being uploaded (by checking the files size), then runs a series of other scripts. The script is in a never ending loop that is "throttled" so that it when it is finding matching files its loop is shorter, but once it stops finding mathing files (in the monitored file system) it slow down until it finds another matching file.
Everything works great except that now I need to have the script monitor the same filesystem for two filenames. Actually they are the same filename but sometimes they are in ALL CAPS and sometimes they are not (for example I might get an upload.0002 or an UPLOAD.0002). Here is the script: 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="/datafiles/str${fileExtension}.asc"
local filePrintPath="/print"
local fileTmpPath="/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 /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:
for fileName in /datafiles/UPLOAD.[0-9][0-9][0-9][0-9] |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Quote:
- Every file in /datafiles: Code:
for fileName in /datafiles/*; do whatever_you_want done Code:
for fileName in /datafiles/file1 /datafiles/file2 /datafiles/file3; do whatever_you_want done /datafiles/[Uu][Pp][Ll][Oo][Aa][Dd].[0-9][0-9][0-9][0-9] Regards. |
|
#3
|
|||
|
|||
|
The syntax for:
Code:
/datafiles/[Uu][Pp][Ll][Oo][Aa][Dd].[0-9][0-9][0-9][0-9] |
|||
| Google The UNIX and Linux Forums |