The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help with exec command and file descriptors II masaki Shell Programming and Scripting 2 01-03-2009 11:27 PM
Accessing input from another file krishnan_6015@y Shell Programming and Scripting 2 11-26-2007 02:04 AM
Help with exec command and file descriptors?? rfourn Shell Programming and Scripting 1 07-18-2007 07:05 PM
How to input .txt file into .xls spreadsheet wereyou Shell Programming and Scripting 1 12-22-2006 03:33 PM
how to get input from file ajaya Shell Programming and Scripting 1 04-05-2006 03:02 PM

 
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 01-02-2003
giannicello giannicello is offline
Registered User
  
 

Join Date: Sep 2001
Location: Phoenix
Posts: 169
exec w/input file

Why is my code not doing what I want it to do? I have 3 files that I want to process
that are in format file123, file456, file789.

Code:
echo "Processing each file one at a time..."

cd $dir
ls -r1 file???.dat > input.dat

exec < input.dat
    IFS='|'
    while read INPUT_FILE ; do
          echo INPUT_FILE = $INPUT_FILE 1>/dev/null
          echo "Processing file $INPUT_FILE..."

          if [[ -s  $INPUT_FILE ]]; then
              ksh script1.ksh
          else
             echo "$INPUT_FILE was empty."
             exit 1
          fi

          echo "Renaming processed file $INPUT_FILE..."
          mv $INPUT_FILE $INPUT_FILE.done
    done

The problem is that as soon as the script1.ksh launches, this main script doesn't wait for all 10 scripts
to finish (script1.ksh ends then calls script2.ksh, which calls script3.ksh, etc..all the
way to script10.ksh) before it attempts to process the second input file. Why?? I was thinking that it would
only execute the second file once I reach the rename part (and that's after it had finished all 10 scripts)
but it doesn't. It kicks off script1.ksh and then it renames my files before, say script5.ksh even had
a chance to work with the input file.

Any ideas on how to make sure all 10 scripts execute for each iteration/each file? Right now, things are getting clobbered...and I want things done in sequence...

Gianni

added code tags for readability --oombera

Last edited by oombera; 02-19-2004 at 04:15 PM..
 

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:38 AM.


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