The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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
How to delete files in UNIX using shell script theguy16 Shell Programming and Scripting 7 04-09-2008 04:40 AM
shell script to find and copy the files creted in the year 2006 to another directory manas6 Shell Programming and Scripting 2 04-01-2008 03:04 AM
shell script: deleting files from a directory onlyc Shell Programming and Scripting 1 07-09-2006 06:41 AM
Can a timeout be specified in a shell script? puneetarora_12 Shell Programming and Scripting 3 06-14-2006 03:24 AM
Timeout period Nadeem Mistry UNIX for Dummies Questions & Answers 4 08-15-2001 09:55 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 03-23-2006
Danny Fang Danny Fang is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 1
UNIX Shell script to chec timeout period when collecting files in directory - HELP

Hi,

I have a shell script which is to perform a check if all 4 particular type of files exists in a directory.
If ALL 4 files are present within a specific Timeframe, then tar these files and zip it.
If not all 4 files are present in the directory after the specific timeframe, then tar whatever files (those that had matched the regex) and zip them.
If it’s within the timeframe all 4 files have not arrived, then the script waits until it has reached the timeframe for any or all of the 4 files to arrive.
The timeframe referred to here is that the arithmetic difference between the current time and the file modification time.

The script I have (BASH) is attached in this posting.

However, this is the problem:
From the script’s output, it did not show the process of obtaining the variables i.e. OSS_INSTANCE, OSS_NAME, BSC_VAL, etc, etc …, for the following 2 files encountered:
1003_oxnn2_BSC48379.2.200603130501.768750
1003_oxnn2_BSC48379.72.200603140501.768761
1003_oxnn2_BSC48379.79.200603140501.768766
The output in Listing 1 is based on the fact it has reached the specified timeframe and all 4 files are in the particular directory. Therefore, it should now tar these 4 files and compress them, in which it did.

Listing 1:
prod-cingtuna\ :/mkl/users/lows >/prodkl/MZ4.0/Cingular/MZ/scripts/NokiaR_RAN-tarNew-2.sh
DATE is Thu Mar 23 20:16:05 SGT 2006
file is 1003_oxnn2_BSC48379.1.200603130501.768754
OSS_INSTANCE 1003
OSS_NAME oxnn2
TMP_VAR BSC48379.1.200603130501.768754
BSC_VAL is BSC48379
NOKIA_BSC_ID is 48379
TIMESTAMP is 200603130501
GRP_DAY 23
hrmin 17:15
GRP_HOUR 17
GRP_MIN 15
NUM_FILES now is 1
CDAY is 23
CHOUR is 20
CMINUTE is 16
E_DAYS is 0
E_HOURS is 3
E_MINS is 1
TOTAL_HOURS away is 3
TOTAL_MINUTES is 181
TOTAL_MINUTES exceeds TIMEOUT
FILES MISSING OR YET TO ARRIVE AFTER TIMEOUT
ERROR_TYPE is MISSING_FILES
flogName is NOKIA-RAN.RAN.MISSING_FILES.200603232016.err
-n Inside tarAndZip_file() ...
TAR_FILE_NAME is 1003_oxnn2_BSC48379.200603130501.tar
a /tmp/osspkg2s/uma/umabass/cs_bsspm_aif/client/out/1003_oxnn2_BSC48379.1.200603130501.768754 1K
a /tmp/osspkg2s/uma/umabass/cs_bsspm_aif/client/out/1003_oxnn2_BSC48379.200603130501.tar.gz 1K
a /tmp/osspkg2s/uma/umabass/cs_bsspm_aif/client/out/1003_oxnn2_BSC48379.72.200603140500.768752 1K
a /tmp/osspkg2s/uma/umabass/cs_bsspm_aif/client/out/1003_oxnn2_BSC48379.79.200603140501.768766 1K
gzip: 1003_oxnn2_BSC48379.200603130501.tar.gz already exists; do you wish to overwrite (y or n)? y
ERROR_TYPE is TIMEOUT_EXPIRED
flogName is NOKIA-RAN.RAN.TIMEOUT_EXPIRED.200603232016.err
file is 1003_oxnn2_BSC48379.2.200603130501.768750
file is 1003_oxnn2_BSC48379.72.200603140501.768761
file is 1003_oxnn2_BSC48379.79.200603140501.768766
OSS_INSTANCE 1003
OSS_NAME oxnn2
TMP_VAR BSC48379.79.200603140501.768766
BSC_VAL is BSC48379
NOKIA_BSC_ID is 48379
TIMESTAMP is 200603140501
GRP_DAY 23
hrmin 16:24
GRP_HOUR 16
GRP_MIN 24
NUM_FILES now is 2
CDAY is 23
CHOUR is 20
CMINUTE is 16
E_DAYS is 0
E_HOURS is 4
E_MINS is -8
TOTAL_HOURS away is 4
TOTAL_MINUTES is 232
TOTAL_MINUTES exceeds TIMEOUT
FILES MISSING OR YET TO ARRIVE AFTER TIMEOUT
ERROR_TYPE is MISSING_FILES
flogName is NOKIA-RAN.RAN.MISSING_FILES.200603232016.err
cp: 1003_oxnn2_BSC48379.79.200603140501.768766 and /tmp/osspkg2s/uma/umabass/cs_bsspm_aif/client/out/1003_oxnn2_BSC48379.79.200603140501.768766 are identical
-n Inside tarAndZip_file() ...
TAR_FILE_NAME is 1003_oxnn2_BSC48379.200603140501.tar
a /tmp/osspkg2s/uma/umabass/cs_bsspm_aif/client/out/1003_oxnn2_BSC48379.1.200603130501.768754 1K
a /tmp/osspkg2s/uma/umabass/cs_bsspm_aif/client/out/1003_oxnn2_BSC48379.200603130501.tar.gz 1K
a /tmp/osspkg2s/uma/umabass/cs_bsspm_aif/client/out/1003_oxnn2_BSC48379.72.200603140500.768752 1K
a /tmp/osspkg2s/uma/umabass/cs_bsspm_aif/client/out/1003_oxnn2_BSC48379.79.200603140501.768766 1K
ERROR_TYPE is TIMEOUT_EXPIRED
flogName is NOKIA-RAN.RAN.TIMEOUT_EXPIRED.200603232016.err
prod-cingtuna\ :/mkl/users/lows >


The output in Listing 2 is to show that all 4 files have arrived, and it’s still within the timeframe specified. Therefore, it should also tar all 4 files and zip them – in which it also did.

Listing 2:
prod-cingtuna\ :/mkl/users/lows >/prodkl/MZ4.0/Cingular/MZ/scripts/NokiaR_RAN-tarNew-2.sh:
DATE is Thu Mar 23 20:37:53 SGT 2006
file is 1003_oxnn2_BSC48379.1.200603130501.768754
OSS_INSTANCE 1003
OSS_NAME oxnn2
TMP_VAR BSC48379.1.200603130501.768754
BSC_VAL is BSC48379
NOKIA_BSC_ID is 48379
TIMESTAMP is 200603130501
GRP_DAY 23
hrmin 20:35
GRP_HOUR 20
GRP_MIN 35
NUM_FILES now is 1
CDAY is 23
CHOUR is 20
CMINUTE is 37
E_DAYS is 0
E_HOURS is 0
E_MINS is 2
TOTAL_HOURS away is 0
TOTAL_MINUTES is 2
TOTAL_MINUTES below TIMEOUT

file is 1003_oxnn2_BSC48379.2.200603130501.768750
OSS_INSTANCE 1003
OSS_NAME oxnn2
TMP_VAR BSC48379.2.200603130501.768750
BSC_VAL is BSC48379
NOKIA_BSC_ID is 48379
TIMESTAMP is 200603130501
GRP_DAY 23
hrmin 20:35
GRP_HOUR 20
GRP_MIN 35
NUM_FILES now is 2
CDAY is 23
CHOUR is 20
CMINUTE is 37
E_DAYS is 0
E_HOURS is 0
E_MINS is 2
TOTAL_HOURS away is 0
TOTAL_MINUTES is 2
TOTAL_MINUTES below TIMEOUT

file is 1003_oxnn2_BSC48379.72.200603140501.768761
OSS_INSTANCE 1003
OSS_NAME oxnn2
TMP_VAR BSC48379.72.200603140501.768761
BSC_VAL is BSC48379
NOKIA_BSC_ID is 48379
TIMESTAMP is 200603140501
GRP_DAY 23
hrmin 20:36
GRP_HOUR 20
GRP_MIN 36
NUM_FILES now is 3
CDAY is 23
CHOUR is 20
CMINUTE is 37
E_DAYS is 0
E_HOURS is 0
E_MINS is 1
TOTAL_HOURS away is 0
TOTAL_MINUTES is 1
TOTAL_MINUTES below TIMEOUT

file is 1003_oxnn2_BSC48379.79.200603140501.768766
OSS_INSTANCE 1003
OSS_NAME oxnn2
TMP_VAR BSC48379.79.200603140501.768766
BSC_VAL is BSC48379
NOKIA_BSC_ID is 48379
TIMESTAMP is 200603140501
GRP_DAY 23
hrmin 20:36
GRP_HOUR 20
GRP_MIN 36
NUM_FILES now is 4
CDAY is 23
CHOUR is 20
CMINUTE is 37
E_DAYS is 0
E_HOURS is 0
E_MINS is 1
TOTAL_HOURS away is 0
TOTAL_MINUTES is 1
TOTAL_MINUTES below TIMEOUT
NUM_FILES IN DIR EQUALS NUMBER OF EXPECTED FILES
-n Inside tarAndZip_file() ...
TAR_FILE_NAME is 1003_oxnn2_BSC48379.200603140501.tar
a /tmp/osspkg2s/uma/umabass/cs_bsspm_aif/client/out/1003_oxnn2_BSC48379.1.200603130501.768754 1K
a /tmp/osspkg2s/uma/umabass/cs_bsspm_aif/client/out/1003_oxnn2_BSC48379.72.200603140500.768752 1K
a /tmp/osspkg2s/uma/umabass/cs_bsspm_aif/client/out/1003_oxnn2_BSC48379.79.200603140501.768766 1K
prod-cingtuna\ :/mkl/users/lows >

bash-3.00$ pwd
/tmp/osspkg2s/uma/umabass/cs_bsspm_aif/client/out
bash-3.00$ ls -l
total 64
-rw-r--r-- 1 lows metrica 351 Mar 23 20:37 1003_oxnn2_BSC48379.200603140501.tar.gz

However, the directory in which my script had intentionally copied the all 4 scripts to be tar-ed and zip-ed only showed 3 files:
a /tmp/osspkg2s/uma/umabass/cs_bsspm_aif/client/out/1003_oxnn2_BSC48379.1.200603130501.768754 1K
a /tmp/osspkg2s/uma/umabass/cs_bsspm_aif/client/out/1003_oxnn2_BSC48379.72.200603140500.768752 1K
a /tmp/osspkg2s/uma/umabass/cs_bsspm_aif/client/out/1003_oxnn2_BSC48379.79.200603140501.768766 1K

For both Listing 1 and Listing 2, could anyone help by pointing out where did I go wrong? Kindly also provide feedbacks and solutions as to how the overall structure of this script can be improved.

Thanks in advance.
Danny
Attached Files
File Type: txt NokiaR_RAN-tarNew-2.txt.txt (8.6 KB, 40 views)
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:03 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0