![]() |
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 |
| Reg :Executing a script through GUI . | shyam.appalla | Shell Programming and Scripting | 2 | 05-30-2008 10:56 PM |
| Print out loop index on the console after executing each sybase DB query | Alaeddin | Shell Programming and Scripting | 2 | 12-16-2007 04:30 AM |
| [AIX] executing script | piooooter | UNIX for Dummies Questions & Answers | 1 | 05-26-2006 12:53 AM |
| executing script | big123456 | Shell Programming and Scripting | 1 | 06-03-2005 07:32 AM |
| RSH use for executing a script | frustrated1 | Shell Programming and Scripting | 6 | 10-02-2003 08:24 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Script not executing second loop
I have a server that receives backup files from several servers. Each server has its own directory to scp their files into, some of the files are received as .tar files and need to be compressed before being dumped. When the scp of the tar file is complete a file named 'flag' is also sent to indicate that the scp of the zip file is complete.
The following script is supposed check for any existing flag files and .tar files and run bzip2 on any .tar files found. The specific problem is that, on the first while loop if no flag or tar file is found the second loop is not initiated. If the data for the first loop exists then both loops run as expected. (Currently only data for two servers are included for testing). I've looked and looked for the error in my logic and it eludes me. Could someone point out my blind spot? The data file being read is appended after the code. Thanks Thumper Code:
#!/bin/bash
#
# set -n
set -x
##########################################################
####################### FUNCTIONS ######################
##########################################################
file_exists () {
echo "ENTERING FILE_EXISTS"
echo "the value of \$1 is ${1}"
echo "the value of \$2 is ${2}"
if [ -e ${1} ] #test for the flag file
then
if [ -e ${2} ] #test for the .tar file
then
`bzip2 ${2}` #bzip the .tar file
`rm ${1}` #remove the flag file
else #no .tar file found
mail -s "No ${2} file found" thumper@somewhere.net
fi
else #no flag file found
mail -s "No ${1} file found" thumper@somewhere.net
fi
return 0
}
#### end
##########################################################
#################### MAIN ################################
##########################################################
while IFS=: read dir sname flag ext
do
VAL_1="/$dir/$sname/$flag"
VAL_2="/$dir/$sname/$ext"
echo ${VAL_1}; echo ${VAL_2}
# echo "Calling file_exists"
file_exists ${VAL_1} ${VAL_2}
# echo "Exited file_exists"
echo "VAL_1 is ${VAL_1}"
echo "VAL_2 is ${VAL_2}"
echo "\$? is $?"
done < /root/scripts/bz-data
# End of script
DATA FOR READ STATEMENT /root/scripts/bz-data archive:yoda:flag:*.tar archive:chewy:flag:*.tar |
|
||||
|
Quote:
Anyhow the OS is # uname -a Linux sport 2.6.11.4-21.17-default #1 Fri Apr 6 08:42:34 UTC 2007 i686 athlon i386 GNU/Linux And the bash version is # bash --version GNU bash, version 3.00.16(1)-release (i586-suse-linux) Copyright (C) 2004 Free Software Foundation, Inc. and the bash version is If anyone knows of a cause for this problem I would appreciate help. Thanks again Thumper |
| Sponsored Links | ||
|
|