Sponsored Content
Top Forums Shell Programming and Scripting What is wrong with this script? Post 302096513 by heprox on Thursday 16th of November 2006 03:38:09 AM
Old 11-16-2006
Question What is wrong with this script?

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

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

What is wrong with my script?

Hey guys, can someone help me with this script... #!/bin/sh dir=`pwd` for i in *.f do if then M=`wc -l < ${i} sed -e 's://.*::' < ${i} | \ (echo "//${i} -"$M ; cat - ) > $i.tmp chmod 700 $i ; mv ${i}.tmp $i ... (6 Replies)
Discussion started by: Lem2003
6 Replies

2. Shell Programming and Scripting

What's wrong with this script

I am trying to create a script but it is giving me errors on Cygwin for the following script. Could someone tell me, what am I doing wrong? choice=1000 echo "choice is $choice" while ; do echo "choice is $choice" echo 'Please select your option:' echo '1. Option 1' echo '2. Option 2'... (3 Replies)
Discussion started by: amitg1980
3 Replies

3. UNIX for Dummies Questions & Answers

what is wrong with this script?

Hi, I have this example script which gives error ": unexpected operator/operand". I need the '' brackets for operator precedence. #!/bin/ksh x="abc" y="xyz" z="123" if -a then print "yes" else print "no" fi Thanks (2 Replies)
Discussion started by: rs1969
2 Replies

4. Shell Programming and Scripting

what is wrong with this script?

Hi I've made a short script but it is not working. Can some pl. help me out in this? ./123.sh #! /usr/bin/ksh # for changing to this directory cd /layered/relational/scripts When I run the above scripts, it doesn't change to the above directory. I don't what is the problem? the... (2 Replies)
Discussion started by: Mike1234
2 Replies

5. Shell Programming and Scripting

Script Gone Wrong

Hello all, so this is a script i did for an assignement, - first option greets the user according to the time after fetching his name - second options isn't implemented - third check the performance according to how many users are using the system - creates a log of names, time and ip of the... (14 Replies)
Discussion started by: ibzee33
14 Replies

6. Shell Programming and Scripting

What's wrong with my script ....

Please see below mentioned my script ... it ran once without any issue .... then after it is not coming out .... please suggest what is wrong? #!/bin/ksh ## if (( ${num_errors} > 0 )); export ACULOG=/home/varshnes/input export num_errors=10 **** Search for 'Start correcting roll up... (7 Replies)
Discussion started by: heyitsmeok
7 Replies

7. UNIX for Dummies Questions & Answers

What's wrong on this script?

I get this error on these lines when i run this script:"for i in /home;do file2=`ls -s $i` if ;then ls - s $i fi done (7 Replies)
Discussion started by: kotsos13
7 Replies

8. Shell Programming and Scripting

Can anyone tell me what's wrong with my script

Hi... I am fed up in file handing with array for comparing.... 1st I want save first 2 columns of file 1 I tried like this,, {getline< "file1";ln=$1; lt=$2}then I read second file's 1st and 2nd column..and saved like this and small calculation and initialization var1 =$1 var2 =$2... (5 Replies)
Discussion started by: Akshay Hegde
5 Replies

9. Shell Programming and Scripting

What is wrong with my script?

Dear All The following is part of my script: echo ${myarray} mytitle=`awk '{print substr(${myarray}, 0, length(${myarray})-4)}' /dev/null` the echo ${myarray} works fine; however, I keep getting following error for the mytitle=.. part: awk: line 1: syntax error at or near { awk: line... (3 Replies)
Discussion started by: littlewenwen
3 Replies

10. Shell Programming and Scripting

Why result is wrong here ? whether break statement is wrong ?

Hi ! all I am just trying to check range in my datafile pls tell me why its resulting wrong admin@IEEE:~/Desktop$ cat test.txt 0 28.4 5 28.4 10 28.4 15 28.5 20 28.5 25 28.6 30 28.6 35 28.7 40 28.7 45 28.7 50 28.8 55 28.8 60 28.8 65 28.1... (2 Replies)
Discussion started by: Akshay Hegde
2 Replies
DTK_NANOSLEEP(3)						Draw Toolkit manual						  DTK_NANOSLEEP(3)

NAME
dtk_nanosleep - high-resolution sleep SYNOPSIS
#include <dtk_time.h> int dtk_nanosleep(int abs, const struct dtk_timespec* req, struct dtk_timespec* rem); DESCRIPTION
The function dtk_nanosleep() allows the caller to sleep for an interval with nanosecond precision. If the argument abs is zero, the speci- fied interval is interpretated as a relative value, otherwise an absolute value. The interval is specified by the req argument which is a pointer to a dtk_timespec structure defined as: struct dtk_timespec { long sec; /* seconds */ long nsec; /* nanoseconds */ }; If interpreted as an absolute value, it represents seconds and nanoseconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC). dtk_nanosleep() suspends the execution of the calling thread until either at least the time specified by req has elapsed, or a signal is delivered that causes a signal handler to be called or that terminates the process. If the call is interrupted by a signal handler, dtk_nanosleep() returns -1, and sets errno to EINTR. In addition, if rem is not NULL, and abs is zero, it returns the remaining unslept time in rem. This value can then be used to call dtk_nanosleep() again and complete a (rela- tive) sleep. RETURN VALUE
On successfully sleeping for the requested interval, dtk_nanosleep() returns 0. If the call is interrupted by a signal handler or encoun- ters an error, then it returns -1 and errno is set appropriately. ERRORS
dtk_nanosleep() will fail if: EINTR The sleep was interrupted by a signal handler. EINVAL The value in the nsec field was not in the range 0 to 999999999 or sec was negative. NOTE
This function is a wrapper to clock_nanosleep(2) if it is provided by the system. Otherwise, it implements the function by using the sleep function with the highest precision available on the system. SEE ALSO
dtk_nanosleep(3), clock_nanosleep(2) EPFL
2011 DTK_NANOSLEEP(3)
All times are GMT -4. The time now is 02:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy