![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| what is wrong with this script? | rs1969 | UNIX for Dummies Questions & Answers | 2 | 11-15-2007 07:16 AM |
| What's wrong with this script | amitg1980 | Shell Programming and Scripting | 3 | 11-12-2007 07:00 PM |
| what is wrong with this script? | hankooknara | Shell Programming and Scripting | 8 | 06-09-2007 12:33 PM |
| what is wrong with this script? | circleW | Shell Programming and Scripting | 2 | 09-28-2004 08:27 PM |
| What is wrong with my script? | Lem2003 | UNIX for Dummies Questions & Answers | 6 | 05-29-2003 01:17 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I keep getting errors messages for the "else" statement at line 81?
Code:
#!/bin/ksh
######### Environment Setup #########
PATH=/gers/nurev/menu/pub/sbin:/gers/nurev/menu/pub/bin:/gers/nurev/menu/pub/mac
:/gers/nurev/menu/adm/sbin:/gers/nurev/menu/adm/bin:/gers/nurev/menu/adm/mac:/ge
rs/nurev/custom:/gers/nurev/fix:/gers/nurev/src_rev/fix:/gers/nurev/opt/path:/ge
rs/nurev/bin:/g/bin:/usr/bin:/etc:/usr/sbin:/usr/ucb:/sbin:.
ORACLE_HOME=/gers/nurev
ORACLE_SID=nurev
export PATH
export ORACLE_HOME
export ORACLE_SID
########## Global Variables ##########
DATE=$(date +%m%d%y)
TIME=$(date +%H%M)
DatafilesDir="/gers/nurev/datafiles"
PrintDir="/gers/nurev/print"
TempDir="/gers/nurev/tmp"
Logfile="/tmp/test_str_process_$DATE.log"
########## Function to Verify File is Completely Uploaded ###########
# 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:-5}
size2=$(ls -l $file 2>/dev/null | awk '{print $5}')
[ ${size1:-1} -eq ${size2:-2} ] && arrived=0
fi
log_it "Arrived is $arrived"
return $arrived
}
######### GERS Processing of File ###########
processFile ()
{
local fileName=$1
local fileExtension=$2
local fileNewName="$DatafilesDir/str${fileExtension}.asc"
local fileODIName="str${fileExtension}.pos"
mv -Eignore $fileName $fileNewName
prepup $fileNewName $fileExtension
mv -Eignore $PrintDir/$fileODIName $TempDir/$fileODIName
save2tmp $fileExtension
call_siu $fileExtension
log_it "Store file $fileName processed at $TIME on $DATE"
}
########## Log File Function ###########
log_it()
{
printf "%s\n" "$*" >> "$Logfile"
}
########## Main Processing ###########
nsec=1
while [[ "$(date +%H%M)" -lt 2340 ]]
do
for fileName in $DatafilesDir/[Uu][Pp][Ll][Oo][Aa][Dd].[0-9][0-9][0-9][0-9]
do
fileExtension=${fileName#*.}
is_file_arrived "$fileName"
if $arrived = 0 then
if [ ! -f "$TempDir/poll_$fileExtension.txt"] then
nsec=1
processFile $fileName $fileExtension
else
log_it "Store $fileExtension is already in process"
fi
else
log_it "Store file $fileName not done uploading at $TIME on $DATE"
fi
done
sleep $nsec
case $nsec in
1) nsec=15;;
15) nsec=45;;
45) nsec=90;;
90) nsec=300;;
300) nsec=600;;
*) nsec=900;;
esac
done
|
|
||||
|
This is what I have:
Code:
nsec=1
while [[ "$(date +%H%M)" -lt 2340 ]]
do
for fileName in $DatafilesDir/[Uu][Pp][Ll][Oo][Aa][Dd].[0-9][0-9][0-9][0-9]
do
fileExtension=${fileName#*.}
is_file_arrived "$fileName"
if [ $arrived = 0 ]; then
if [ ! -f "$TempDir/poll_$fileExtension.txt" ] then
nsec=1
processFile $fileName $fileExtension
else
log_it "Store $fileExtension is already in process"
fi
else
log_it "Store file $fileName not done uploading at $TIME on $DATE"
fi
|
|
||||
|
I just got my mistake, I was missing the ";" after the brackets. Now I'm getting a different error:
Code:
+ nsec=1 + date +%H%M + [[ 0102 -lt 2340 ]] + fileExtension=0004 + is_file_arrived /gers/nurev/datafiles/upload.0004 + [ = 0 ] test_str_process[76]: test: 0403-004 Specify a parameter with this command. + log_it Store file /gers/nurev/datafiles/upload.0004 not done uploading at 0102 on 111606 |
|
|||||
|
if [ ! -f "$TempDir/poll_$fileExtension.txt"] then
you need spaces surrounding [ ] in an if statement. You are missing a space before ]. Dang! vino beat me to it... ![]() Last edited by Perderabo; 11-16-2006 at 04:54 AM.. Reason: vino beat me to it |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|